Oracle Java JDK: Difference between revisions

m Kangtain moved page Software/Oracle Java JDK to Oracle Java JDK over redirect
No edit summary
Tags: Mobile edit Mobile web edit
 
Line 2: Line 2:


===What’s New in Java 18===
===What’s New in Java 18===
*New Oracle Cloud Infrastructure (OCI) native service to help manage Java runtimes and applications on-premises or on any cloud.
*New Oracle Cloud Infrastructure (OCI) native service to help manage Java runtimes and applications on-premises or on any cloud.
*Sets UTF-8 as the default charset of the standard Java APIs
*Sets UTF-8 as the default charset of the standard Java APIs
Line 22: Line 21:
===2. Install the .deb package===
===2. Install the .deb package===
*Next, press <code>Ctrl+Alt+T</code> on keyboard to open terminal. When it opens, run the command below to install the package you just downloaded:
*Next, press <code>Ctrl+Alt+T</code> on keyboard to open terminal. When it opens, run the command below to install the package you just downloaded:
<syntaxhighlight lang="shell">
 
cd ~/Downloads && sudo apt install ./jdk-18_linux-x64_bin.deb
cd ~/Downloads && sudo apt install ./jdk-18_linux-x64_bin.deb
</syntaxhighlight>


===3. Set JDK 18 as default===
===3. Set JDK 18 as default===
Line 32: Line 30:
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-18/bin/java 1
sudo update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk-18/bin/java 1


</syntaxhighlight><syntaxhighlight lang="shell">
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-18/bin/javac 1
sudo update-alternatives --install /usr/bin/javac javac /usr/lib/jvm/jdk-18/bin/javac 1
</syntaxhighlight><syntaxhighlight lang="shell">
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-18/bin/jar 1
</syntaxhighlight>Similarly, add links for other executable files (e.g., jarsigner, jlink, javadoc) as need.


'''b.''' Next, run the commands below one by one, and type number to select Java JDK 18 as default.<syntaxhighlight lang="shell">
sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/jdk-18/bin/jar 1
sudo update-alternatives --config java


</syntaxhighlight><syntaxhighlight lang="shell">
Similarly, add links for other executable files (e.g., jarsigner, jlink, javadoc) as need.
sudo update-alternatives --config javac


</syntaxhighlight><syntaxhighlight lang="shell">
'''b.''' Next, run the commands below one by one, and type number to select Java JDK 18 as default.
sudo update-alternatives --config jar
 
</syntaxhighlight>When done, verify by running command in terminal:<syntaxhighlight lang="shell">
sudo update-alternatives --config java
 
sudo update-alternatives --config javac
 
sudo update-alternatives --config jar
 
When done, verify by running command in terminal:<syntaxhighlight lang="shell">
java -version
java -version


</syntaxhighlight><syntaxhighlight lang="shell">
javac -version
javac -version
</syntaxhighlight>


===4. Set JAVA_HOME===
===4. Set JAVA_HOME===


'''Option 1''' Set <code>JAVA_HOME</code> for current console, that will work until you close it:<syntaxhighlight lang="shell" line="1">
'''Option 1''' Set <code>JAVA_HOME</code> for current console, that will work until you close it:
export JAVA_HOME=/usr/lib/jvm/jdk-18
 
setenv JAVA_HOME=/usr/lib/jvm/jdk-18
export JAVA_HOME=/usr/lib/jvm/jdk-18
</syntaxhighlight>'''Option 2''' To make it permanent, create and edit config file via command:<syntaxhighlight lang="shell">
setenv JAVA_HOME=/usr/lib/jvm/jdk-18
sudo gedit /etc/profile.d/jdk.sh
 
</syntaxhighlight>then add following lines:<syntaxhighlight lang="shell" line="1">
'''Option 2''' To make it permanent, create and edit config file via command:
export J2SDKDIR=/usr/lib/jvm/jdk-18
 
export J2REDIR=/usr/lib/jvm/jdk-18
sudo gedit /etc/profile.d/jdk.sh
export PATH=$PATH:/usr/lib/jvm/jdk-18/bin:/usr/lib/jvm/jdk-18/db/bin
 
export JAVA_HOME=/usr/lib/jvm/jdk-18
then add following lines:
export DERBY_HOME=/usr/lib/jvm/jdk-18/db
 
</syntaxhighlight>And create anther one for C shell:<syntaxhighlight lang="shell">
export J2SDKDIR=/usr/lib/jvm/jdk-18
sudo gedit /etc/profile.d/jdk.csh
export J2REDIR=/usr/lib/jvm/jdk-18
</syntaxhighlight>add following lines and save it:<syntaxhighlight lang="shell" line="1">
export PATH=$PATH:/usr/lib/jvm/jdk-18/bin:/usr/lib/jvm/jdk-18/db/bin
setenv J2SDKDIR /usr/lib/jvm/jdk-18
export JAVA_HOME=/usr/lib/jvm/jdk-18
setenv J2REDIR /usr/lib/jvm/jdk-18
export DERBY_HOME=/usr/lib/jvm/jdk-18/db
setenv PATH ${PATH}:/usr/lib/jvm/jdk-18/bin:/usr/lib/jvm/jdk-18/db/bin  
 
setenv JAVA_HOME /usr/lib/jvm/jdk-18
And create anther one for C shell:
setenv DERBY_HOME /usr/lib/jvm/jdk-18/db
 
</syntaxhighlight>Finally, change the permissions via command, and it should take place at the next boot.<syntaxhighlight lang="shell">
sudo gedit /etc/profile.d/jdk.csh
sudo chmod +x /etc/profile.d/jdk.csh /etc/profile.d/jdk.sh
 
</syntaxhighlight>
add following lines and save it:
 
setenv J2SDKDIR /usr/lib/jvm/jdk-18
setenv J2REDIR /usr/lib/jvm/jdk-18
setenv PATH ${PATH}:/usr/lib/jvm/jdk-18/bin:/usr/lib/jvm/jdk-18/db/bin  
setenv JAVA_HOME /usr/lib/jvm/jdk-18
setenv DERBY_HOME /usr/lib/jvm/jdk-18/db
 
Finally, change the permissions via command, and it should take place at the next boot.
 
sudo chmod +x /etc/profile.d/jdk.csh /etc/profile.d/jdk.sh


==Source==
==Source==