I am not using any IDE (some Development Environ.) hence have to go through the hassles of downloading JDK and setting the compiler path also called as CLASS PATH.
JDK is the Java Compiler. You need to install the JDK in your machine.
The source code files are to be saved with an extension .java. After compilation a new file (which is the executable) gets created and has the same file name as the source code file but has a new extension called .class. You can take this .class file to any machine and run your program, the machine need not contain your source code.
After installing JDK you need to set the Class Path. Locate the JDK Bin folder and note/copy the path.
Go to Control Panel > System > Advanced Tab > Environment variable; in system variables you will find a variable called path - edit this; to the existing text add a ';' and paste the class path.
Now that the class path is set, you are ready for compiling your source code. Go to Command Prompt (Run > CMD) and traverse to the folder where you have saved your .java file. From here type javac
Now to run the program. From command prompt type java
Lesson1 Over.
BTW here is the snippet of HelloWorldApp -
/**
* The HelloWorldApp class implements an application that
* simply prints "Hello World!" to standard output.
*/
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!"); // Display the string.
}
}
No comments:
Post a Comment