If you want to build native applications in Android,
you've got to know Java---there's no way around it. Yes, there are
tools like PhoneGap, Titanium etc. but you will eventually hit
limitations and ceilings if you choose to code on non-native development
platform. So learn Java, it's not that bad.
- Set up the development environment
- Get some tools
- Learn to construct the simplest program
- Learn the keywords
- Dig some OOP, actually dig a lot of OOP
- Learn how Java treats value types and reference types
- Learn how to write methods and what access control means
- Discover how GC works
- Learn the data types
- Exercise on some operators
- Dig the control structures, so you can learn block level practices
- Learn how Java does Exception handling
- Some tinsy bitsy java.lang.Util
- Some tinsy bitsy I/O
- Learn parameter passing
- Now, the Thread
- Do the simplest UI in java.swing
- Do the simplest event handling (actionListeners)
- Learn how to use inner classes
- Do some basic CRUD (Create, Read, Update, Delete) using SQLite
- Dig (but not too deep) some sockets
- Exercise on some httpClient programs
- Get some XML
- Learn ANT a little bit
1. Set up the environment
Whether you are working on Windows, Linux or OSX, the downloads can be found at Oracle Technet site. Choose just the JSE without the bundles, to keep it simple.
OSX (Lion and Mountain Lion) actually has a simpler way of downloading. Open a Terminal.app, then type java on the command line. OSX wizards will kick in and ask you to download the JDK. Just sayyes to prompt and Java installation will kick in.
If you are using Windows, you will download the JDK (Java Development
Kit), get the latest stable release. Be careful that you are downloading
the JDK and not the JRE (Java Runtime Environment) only, you need the
JDK to create Java apps.
Install what you downloaded, it will guide you through the installation
process. The questions are straight forward so they don't need to be
expounded here.
Set up the PATH and CLASSPATH variable
NOTE for OSX Users - do absolutely nothing, the CLASSPATH AND PATH variable are already setup for you
On Windows;
- Open the System window via the Control Panel, go to Advanced, then Environment variables
- Create a variable named JAVA_HOME, the value is where the JDK is installed, if you said yes to the defaults of the installation, it must have been in c:Files1.7xxxxxx.
- Edit the PATH variable (on the same window). There is an edit button for the PATH variable.
- Append this entry to the PATH variable - ;%JAVA_HOME;.%. The semicolons and the dot are pretty important, so type this slow. If you forget to put these in, you will encounter Bad command or file name kinds of errors later when you execute java and javac
- Create another variable names CLASSPATH, put the value %JAVA_HOME.jar;.% -- again, don't forget the semi colon and the dot at the end
2. Get some tools
Get Apache Ant and a decent program editor. Yes you can use notepad, you
can use vi, even nano---that is really up to you. I won't even
prescribe an editor at this point, this is the subject of a really
intense, almost-religious but quite pointless debate. Just keep coding
and try out a couple of editors. Don't get cheap, not because it's free
it is the best. I like opensource, I love opensource, but it doesn't
mean I will always use it. Choose the best tools for the job, even if it
costs money.
With that disclaimer out of the way, I do use the following editors; Vi
and TextMate (if you are on the Windows platform, the e-TextEditor is
fine too)3. Learn how to write the simplest programs
Do the Hello World program.
It's mundane, boring and dry but its the simplest program. You need to
know how to write the simplest programs before you can try out the more
complex ones. This is a larger discussion, so I wrote it here
4. Learn the keywords of Java
There are a couple of things you will name in Java---meaning, you will
think of the name and declare it in your code. These are names of classes, variables, methods, interfaces, parameters passed to methods and packages. Collectively, these are known as Java identifiers.
Rules to remember when creating identifiers
- You can use alphanumeric characters, but the first letter can't be a number
- You can't use special characters, but you can use the dollar sign and underscore
- You can't use a Java keyword (also known as reserved word). You also can't use a Java literals like true, false or null
The Java keywords
for while do throw
case try catch return
goto [not used]
break continue
byte short int long float double boolean char
if switch throws else
finally class interface implements extends static new this super
public private protected package default
native transient synchronized import instanceof volatile
void abstract final assert enum strictfp
const[not used]
5. Dig some OOP, dig a lot of it
OOP is short for Object Oriented Programming. Java is an object oriented
language. Sure you can write all of your codes inside public static
void main, but that will not take you far in Android when you encounter
stuff like class MySplashPad extends Activity.
OOP is so entrenched in Java---in fact, I think a little bit too
entrenched that some developers I know get over excited about creating
objects, so they create a gazillion of it. Anyway, I hope you learn
temperance about creating objects in your own coding journey, but the
point remains, you need to know OOP. Read more here ...
- Learn how Java treats value types and reference types
- Discover how GC works
- Learn the data types
- Exercise on some operators
10. Dig the control structures, so you can learn block level practices
Your ability to direct and command the flow of control in your program
is one of the defining skills for a programmer. There are basically 3
ways that you can arrange the commands in your program code. They are;
- You can execute commands one after another -- sequencing
- You can execute certain commands when certain conditions are met -- branching
- You can keep on repeating certain commands while certain conditions are still true -- looping or iteration. Continue reading about control structures ...
- Learn how Java does Exception handling
- Some tinsy bitsy java.lang.Util
- Some tinsy bitsy I/O
- Learn parameter passing
- Now, the Thread
- Do the simplest UI in java.swing
- Do the simplest event handling (actionListeners)
- Learn how to use inner classes
- Do some basic CRUD (Create, Read, Update, Delete) using SQLite
- Dig (but not too deep) some sockets
- Exercise on some httpClient programs
- Get some XML
- Learn ANT a little bit

Walang komento:
Mag-post ng isang Komento