How to Run a Java Program Script in Ubuntu
To run Java programs, or scripts, in Ubuntu and other Linux distributions, you must first have a Java runtime environment installed. There are open-source Java packages available, but since the Sun Java package is available from the "Universe" repository, it is best to install that package. The Sun Java package is the package created directly from the Sun Microsystems binaries. Once the Java packages are installed and set up correctly, the script can be run from the command line.
Instructions
-
-
1
Open a terminal window. This is where you will type the following commands.
-
2
Type the command "sudo apt-get install sun-java6-bin, sun-java6-jre" to install the proper Java packages.
-
-
3
Type the command "sudo update-java-alternatives --set java-6-sun" to correctly set the correct packages as default.
-
4
Type the command "cd <path_to_java_program>" to navigate to the directory where the Java script is held. Replace "<path_to_java_program>" with the correct path for your system.
-
5
Type the command "java <java_program>" to execute the program. Replace "<java_program>" with the correct name of the script you want to run.
-
1
Tips & Warnings
The Java packages can also be downloaded directly from the Java website (see Resources).