With Java, you can run cross-platform applications on Mac OS-X, Linux, and Windows (as well as other operating systems) without having to modify them. You can install Java on a GNU/Linux machine easily and there are also many ways for users with very little technical knowledge. Just because you have a Linux computer, doesn't mean you should miss out on a great application!
Step
Method 1 of 5: Manually Installing Java (Non-RPM Method)
This is a common method that can also be run on GNU/Linux clones that don't support RPM. This method does not require computer administrator approval and you can install multiple versions of Java on one computer.
Step 1. Download the JDK
- Click the "Download" link above the Java Platform (JDK) 7u9.
- Accept the license and proceed to the next step.
Step 2. Choose the right download file
Under "Product/File Description" you must select the Linux option that suits your computer. For example, if you are running Linux x86 (32 bit), you need to select the “*.tar.gz” version.
Step 3. Download the file in.gz format
Save the file in your GNU/Linux machine.
Step 4. Open the directory where the downloaded file is stored
You don't need to be root (a user who has full access to the computer), you just need to have access to the directory you will use to store Java programs. If your administrator doesn't support it, you can save Java in the Home directory or (better) the Shared Network directory.
Step 5. Open the downloaded file
For example, you can do this in your Home directory. Opening the file will create a new directory titled “jdk1.7.0_09”. Now, Java is installed.
- The Java JRE is more free and can be moved easily from one place to another by simply copying the entire file.
- You can install different JREs this way. JREs in different versions can run together and can be used if there is software that requires an older version to run.
Step 6. Run Java
Java programs that you can run are located in the subdirectory entitled "bin". This installation method will not form the usual Java command. You will have to do this manually or always include the full path in your startup scripts.
Method 2 of 5: Manual RPM Method
This method is the "more correct" way to install Java because it allows the installer to check for missing dependencies on the library system. However, this method is not applicable in all versions and some may fail even on systems that support RPM. (Although the current Java installer is more self-contained and the requirements are usually few.)
Step 1. Download the JDK
- Click the "Download" link above the Java Platform (JDK) 7u9.
- Accept the license and proceed to the next step.
Step 2. Choose the right download file
Under "Product/File Description" you must select the Linux option that suits your computer. For example, if you are running Linux x86 (32 bit), you need to select the “*.rpm” version, for example “jdk-7u9-linux-i586.rpm”.
Step 3. Download the.rpm file
Save the file into your GNU/Linux machine.
Step 4. Log in as root and go to the directory where the downloaded files are stored
You can also become root by running SU and entering the superuser password.
Step 5. Install the RPM file
Type rpm -ivh filename.rpm where filename is the name of your.rpm file. (Like jdk-7u9-linux-i586.rpm).
- You may get a message stating that the program “rpm” is not installed.
- If the problem is that the program “rpm” is not installed, you will need to install it by typing sudo apt-get install rpm. Enter your password and the program is ready to run.
Step 6. Create a symbolic link
If you want to run this version of the Java interpreter or compiler from any existing directory on your GNU/Linux system, you'll need to create some symbolic links:
- sudo ln -s -v jdk1.7.0_09/bin/java /usr/bin/java
- sudo ln -s -v jdk1.7.0_09/bin/javac /usr/bin/javac
- Remember, with this method, you may find broken dependencies. It's better to use an installer package that can handle all dependencies because you can't use Java until all errant dependencies are handled.
Method 3 of 5: Installing Java on Ubuntu Using the GUI Package Manager
Step 1. Open the package manager
You can also use Synaptic or Adept Manager.
Step 2. Install Open JDK
The Java JDK and JRE are not available for installation via the Package Manager GUI. Instead, you must install the Open JDK.
- Do a search for openjdk-7-jdk.
- Select openjdk-7-jdk for installation. Depending on the existing package manager, you will be asked to choose to install the required dependencies or the package manager will automatically select the required dependencies without any confirmation. For example, "openjdk-7-jre" is already selected by the Synaptic Package Manager. If you want to use Java as a plugin in your browser, select the option to install "icedtea-7-plugin".
Step 3. Apply changes
Click the button to apply the changes. Depending on the package manager you are using, a window will appear asking for your approval to apply the changes.
Step 4. Wait for Java to install successfully
Method 4 of 5: Installing Java on Ubuntu Using the Console
Step 1. Enter one of the commands below into your console program:
- sudo apt-get install openjdk-7-jdk openjdk-7-jre (if you don't want to install the plugin on your browser)
- sudo apt-get install openjdk-7-jdk openjdk-7-jre icedtea-7-plugin (if you want to install the plugin on your browser)
- apt-get can automatically handle existing dependencies and provide a list of changes for confirmation.
Step 2. Enter y to approve installation
Method 5 of 5: Ubuntu OpenJDK Method Using Console
Ubuntu no longer supports Oracle Java packages, but does support OpenJDK.
Step 1. Enter one of the commands below into your console program:
- If you don't want to install the plugin in your browser: sudo apt-get install openjdk-6-jre.
- If you want to install a plug-in in your browser: sudo apt-get install openjdk-6-jre icedtea6-plugin
- If you are using a server without graphics and want a dedicated environment for running server applications (such as Tomcat or Glassfish): sudo apt-get install --no-install-recommends openjdk-6-jre-headless
- If you need the full JDK (for writing Java programs): sudo apt-get install openjdk-6-jdk
- apt-get can automatically handle existing dependencies and provide a list of changes for confirmation.
Step 2. Enter y to approve installation
Tips
- Even if you're not familiar with the console method, it's easier to do than the GUI method.
- If you find a guide on your distribution, we recommend using it because on some existing distributions, the software repository comes with Java (which is to your advantage).
- It's easier to install from storage than to download it on the Oracle site.
- Another tip for following through with the rpm installation process is to use 'rpm -ivv … ' which will fire up verbose output and give you a lot of information about the install at the time of the install process. You can do the same with any other rpm activity to get an explanation of the current activity.
- On Linux Red Hat 8.0, launch the Nautilus file manager, open the directory, and click on the rpm file name that will initiate the installation process. However, this method no longer works on Fedora Core 4 (this has not been tried on any other FC version). In fact, if you do this, you will get a warning message telling you that the file name indicates that the file is not executable even if the contents of the file are of an "executable" type.