Running Java Programs
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Running Java Programs
How to run Java Programs
- To run any program listed in this section you will need Java, recommended Java 1.6 for all operating system. Please check if you have Java on your system before downloading it.
- Once you have downloaded and Installed Java, you have a variety of IDEs [Integrated Development Environments] that help you develop programs, including mine called JAssist but supports only Windows. This step is not necessary but let's you skip the trouble of compiling which is rather lengthy to do manually.
- Now you can Copy the code to the file and save it with the Name of the class and the extension *.java
Ex: PrimeNumber.java when class name is PrimeNumber - Compile the file, you'll end up with 2 files in your directory - a .java file and another .class file.
This new .class file is your Java ByteCode - a special language that only the Java Interpreter understands. - Now run it, entering any extra details if specified.
NOTE : If you followed all the above steps then the program will definitely work.
Re: Running Java Programs
How to Compile and Run [Command-Line Method]
When it comes to Compiling and Running Java programs there are Two Commands -
- javac.exe
- java.exe
To use either of these tools you have to change your current directory to the Java Bin Directory that looks a lot like - C:\Program Files\Java1.6\bin
- Code:
cd C:\PROGRA~1\Java\bin
The javac tool (Compiler) converts your source code i.e. your Java file into the Java ByteCode i.e. your Class file so that it can be understood by the Interpreter.
- Code:
javac fileName.java
The java tool (Interpreter) executes your Class file and shows the output.
- Code:
java fileName
LFPS - Forum :: Study Corner :: Computers :: Java :: Snippets
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|
Tue Feb 14, 2012 9:02 pm by Sujith
» Kolaveri Di
Tue Nov 22, 2011 5:11 pm by Sujith
» Plane of Remembrance
Mon May 23, 2011 7:44 am by Sujith
» Board Exam Results 2011
Fri May 13, 2011 10:19 pm by Sujith
» Source Code
Wed May 04, 2011 8:06 pm by Sujith
» Rio
Wed May 04, 2011 8:04 pm by Sujith
» Fast and Furious 5
Wed May 04, 2011 7:56 pm by Sujith