LFPS - Forum
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Running Java Programs

Go down

Running Java Programs Empty Running Java Programs

Post by Sujith Tue Jul 06, 2010 10:08 pm

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.
Sujith
Sujith
LSF Expert
LSF Expert

Posts : 126

http://osalfps.org

Back to top Go down

Running Java Programs Empty Re: Running Java Programs

Post by Sujith Thu Jul 08, 2010 7:18 pm

How to Compile and Run [Command-Line Method]

When it comes to Compiling and Running Java programs there are Two Commands -

  1. javac.exe
  2. 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

Sujith
Sujith
LSF Expert
LSF Expert

Posts : 126

http://osalfps.org

Back to top Go down

Back to top

- Similar topics

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