Hello ubuntu users!! So are you interested in Java & wanna to install JDK & JRE in ubuntu? In ubuntu, you don't need to set any path first for executing your program using terminal. Follow these steps:
- Go to Applications> Accessories> Terminal (Or use shortcut Ctrl+Alt+T).
- Type "sudo apt-get install sun-java6-bin sun-java6-jre sun-java6-jdk" without quotes.
- It will install JDK & JRE.
- After installing, check installation by entering javac & java in terminal. If these commands execute, that means you have installed JDK & JRE successfully.
- Next step is to execute your program (Suppose you have program file named Hello.java in your home directory).
- Type javac Hello.java in terminal, then java Hello
Note: If you save your java file in any other directory, then you first need to change your directory path otherwise terminal will display error as "No such file or directory".