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 Uninstall openjdk sudo apt-get purge openjdk Go to this blog post and run all steps until 4. Java HotSpot(TM) 64-Bit Server VM (build 9.0.1+11, mixed mode) So after spending a lot of effort on such a common case I decided to add this post. 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) Sudo update-alternatives -set "javac" "/opt/jdk-9.0.1/bin/javac" 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 the /opt directory, you should see the Java installation directory.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |