Java is a programming language which is most popular because of its operating system independence. The platform independence of Java is provided because of the runtime provided by different operating systems. Java comes in two flavour:
Current Java version is 6.0+. However the older versions are still prevalent in many Production environments.
Downloading and installing Java
Download Java from http://www.java.com/en/download/index.jsp
This contains download for Windows, Solaris and Linux. For Linux system you can use their respective utilities to install. For example in OpenSuse you can use the yast. After Oracle takeover of Sun, one has to accept the agreement before downloading the Java SDK.
After Java is downloaded define the variables as follows:
Similarly in unix and Linux based systems, set the JAVA_HOME and path to the location.
If you intend to write many java classes using plain editors, atleast set the present directory to your class path. e.g in Windows SET CLASSPATH=%CLASSPATH%;.
Running Java
Open your text editor and write a java file. A java file ends with extension .java. Let's give the file name as HelloOyeJava.java. Everything in Java is a class so we will need to write the class. Also note that the file name is the same as class name.
HelloOyeJava.java
public class HelloOyeJava {
public static void main(String[] args) {
System.out.println("Hello Oye Java");
}
}Now open a command prompt/terminal and go to the directory where you have saved the above Java file. run the following command
javac HelloOyeJava.javajavac is the compiler which compiles the java file and makes a class file out of it.If the program is successful than you will see one more file HelloOyeJava.class. To run the file put the following command
java HelloOyeJavaIt should show the output Hello Oye Java in console.
For better development use one of the IDE.
Add new comment