Outdoors, Green Living, Homesteading, Sustainable living, Green Building

Posts tagged “Java Hello World

Java ITM (In Ten Minutes)

WANTED! Comments. Not wanted! Compliments. If you want your comment to be accepted first you must not be a spammer that WordPress recognizes and second you need to comment specifically on some of the article’s specific material or facts.

The Survival Pod Cast
Off Grid Net

ITM (In Ten Minutes)
I’m not sure if these articles/tutorials mean you will learn it in ten minutes or it simply took me around ten minutes to write it. But they are meant to hopefully get someone started.
Java ITM
In order to build a Java application follow a few steps I list below.

I) Download the Java Developers Kit (sometimes they call it JDK sometimes SDK who knows might be called ODK since Oracle has bought Java) Also note that IBM has a developers Kit and there is now an Open JDK as well. In this tutorial I am specifically talking about the developers kit from http://java.sun.com. There are several versions of this kit called SE, EE, ME etc. get the SE (Standard Edition) version. Find the one for your operating system and install it.

II) Lets say you installed the windows version and you put it in c:\java\sdk folder. Open up a command window by going to [start][run] then use “cmd”. I will not bother to teach you DOS commands in this section (see the scripts section) Find the bin folder. Here you will see a couple of important files. “java.exe” is one and “javac.exe is the other.

III) Open up notepad.exe (a text editor) and create a file named MyFirstApp.java. Within this file write the following…

public class MyFirstApp {
  public static void main(String args[]){
    System.out.println(“Hello World!”);

This would be the famous hello world application for the console of course.

IV) Next save this and close notepad. Compile this with the command “javac MyFirstApp.java”. If it goes well you will see no errors and a new file called MyFirstApp.class. This is the “bytecode” which the Java virtual machine(JVM) will now interpret (run/execute).

V) You may run (execute) this with the command “java MyFirstApp”. If all goes well you should see the text “Hello World!” appear in the console. You may alter the text in the main method and add extra System.out.println(); calls to your hearts content if you like. Congratulations You are now a Java Programmer. At http://java.sun.com/tutorial you will find a nice tutorial to help you along your new path. Note also that this application you just created would run without change on a Mac or any variety of Unix as well maybe even IBM’s OS2 Warp or possibly on a “Main Frame” operating system. It will run on any system which has a Java Virtual Machine installed. The only issue you could run into might be a Version issue. With such a simple application as this it is unlikely.

VI) One last note, you could have problems with system path, I won’t explain here. And you might have problems with an environment variable setting called CLASSPATH. JAVA_HOME is another one to look into. I will now direct you to internet forums or internet relay chat for further assistance. You would need to seek help concerning your operating system (windows, unix, mac, other) and environment variable settings.