![]() We will run a very simple Hello world program to test our Oracle JDK 9 Installation on Ubuntu.įirst, create a file called HelloWorld. Javac 9.0.1 Compiling and running a Java application Java HotSpot(TM) 64-Bit Server VM (build 9.0.1 11, mixed mode) Java(TM) SE Runtime Environment (build 9.0.1 11) Now the installation of JDK 9 is complete, we can run java and javac command from the Ubuntu command line. ![]() (The same way you can also set other binaries including javadoc, jshell, jar and javap) Type in sudo apt-get install software-properties-common and press Enter. Press Y if prompted, then press Enter 3 Enter the Java installation command. Sudo update-alternatives -set "javac" "/opt/jdk-9.0.1/bin/javac" Type in sudo apt-get purge openjdk-\ Press Enter Type in your password if prompted. Then, set Java Development Kit 9 as the default Java version: sudo update-alternatives -set "java" "/opt/jdk-9.0.1/bin/java" Sudo update-alternatives -install "/usr/bin/javac" "javac" "/opt/jdk-9.0.1/bin/javac" 1 We do this by using the update-alternatives command.įirst add the Oracle java 9 and javac compiler to the alternatives: sudo update-alternatives -install "/usr/bin/java" "java" "/opt/jdk-9.0.1/bin/java" 1 We need to set Oracle JDK 9 as the default Java version in our Ubuntu Server. ![]() Save and source the /etc/bash.bashrc file to apply the new changes: source /etc/bash.bashrc Set Oracle JDK 9 as default Java version Open /etc/bash.bashrc file in any text editor like nano, vim or gedit and add the following lines at the end: export JAVA_HOME=/opt/jdk-9.0.1 Next, we need to set JAVA_HOME environment variable and add JAVA_HOME to the PATH variable. Name of the directory should be something like "jdk-9.0.1" (Depends on the version you downloaded). In your terminal, use the following command. In the /opt directory, you should see the Java installation directory. Install OpenJDK 11 APT Method with Ubuntu The first and most recommended option is to install OpenJDK using the default Ubuntu 20.04 repository.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |