How to Program in Java!!

Go down

How to Program in Java!! Empty How to Program in Java!!

Post  THE GIVEAWAY BLOG!! on Mon Apr 21, 2014 5:54 pm

To program in Java (not JavaScript, an unrelated language), you need a compiler, a program to convert Java source code to bytecode. In the old days, the only option was Sun’s JDK; but now you have many options, including the GNU GCJ which creates class files or native exe files, andjikes, IBM’s open source contribution. You also will need a Java virtual machine, which is a “machine within a machine” which understands Java bytecodes and translates them into machine language on the target processor. There are many available, but you can never go wrong with thejavac compiler and java JRE virtual machine included with Sun’s Java standard edition.

Program in Java Step 1.jpg
Download the correct package for your platform. Windows and Solaris users should visit Oracle’s Java SE page to download a package, Macintosh users will find they already have the Java SE installed. For maximum portability, it may be better to get an older edition; not all your potential users will have the latest JVM installed. Alternatively, use an open-source or other third-party compiler such as GCJ or jikes, and compile to a native executable or run it with the Java JRE.
Learn to use an IDE. Eclipse and NetBeans are two of many other IDEs that are here to help us write the code easier — they report any errors as you code, they help with methods, imports and many more.

Program in Java Step 2.jpg
Learn Edit-Compile-Test cycle. You should start with the Hello World program.

Program in Java Step 3.jpg
Create your own or edit other people’s class(es).

Program in Java Step 4.jpg
Compile to class file(s).

Program in Java Step 5.jpg
Run the program with the Java executable, or as an applet in a browser. If the functionality isn’t correct, or you want to add more features, start again at step 1.

Program in Java Step 6.jpg
Program in Java Step 7.jpg
If you can afford it, buy a good book about Java programming and carefully read the beginning. With this language, the beginning is more difficult than later steps.
Check out sites such as, Javacooperation, Cokeandcode and Oracle’s website for resources/tutorials.

Program in Java Step 8.jpg
Read up and follow a Java tutorial (one of the first recommended tutorials could be a tutorial on collections).

Program in Java Step 9.jpg
For specific info on the classes, methods, and variables, visit Oracle’s API

Program in Java Step 10.jpg
If you face any problems, always try a web search. There are a lot of good articles about Java on the web.

Program in Java Step 11.jpg
Program in Java Step 12.jpg
Don’t reinvent the wheel. Java was always about reusing open-source libraries. If you need something that is not commonly used, there’s usually a library that helps you. Check Java-Sources and Ohloh,

After you get some experience, try to get official programmer certification from Sun Microsystems itself. This is a lot more serious than any other certification you can get from the third parties.
Keep your code organized and add lots of comments for easy reading, remembering, and updating.
Learn technologies in which Java is strong: network communication, database connection, web development, etc.
Unnecessarily long methods (the Java name for subroutines) are looked down upon since they make your code hard to read and difficult to update. Learn to factor your code into small, precise modules that do one thing well.
Practice makes perfect.
Don’t use “magic numbers” if you can help it. Magic numbers are numbers and values that are distributed through your code when they should be defined as a variable, so they can be reused, and explained in a comment so what they represent can be understood. This makes code easier to maintain and update.
Master JUnit and write automatic tests that check the consistency of your program. Most serious projects do this.
Go through the API’s provided with the SDK. Make a habit of reading the description of the methods and classes. This will help you remember the method or class used the next time you need it.
After you master the basics, try to join the existing open source project and work together with other people. From the viewpoint of learning, this is more efficient than to develop something large and complex by yourself.
Bookboon has some good free books on Java for beginners

It is usually not necessary to pay for Java courses that may be very expensive and offer little value. Unless you want to learn something specific, it is frequently better just to do more programming yourself, and learn from other people’s open-source programs.

Posts : 161
Join date : 2012-06-11
Age : 31
Location : Malaysia

Back to top Go down

Back to top

Permissions in this forum:
You cannot reply to topics in this forum