Welcome to my blog, hope you enjoy reading
RSS

Tuesday 25 June 2013

Compiling and Running Java Programs in Terminal on Ubuntu

Compiling and Running Java Programs in Terminal on Ubuntu

 You can install the open Java JDK by opening a terminal and running:

Code:
  • sudo apt-get install openjdk-6-jdk
this will also setup the classpath for you. Now you can simple compile and run you java source with the normal javac / java commands. Lets assume your file is called Myprog.java (with the class called Myprog) and is in your home folder... you can compile with:

Code:
  •  javac Myprog.java
Then run it with:

Code:
  •  java Myprog

0 comments: