This weblog submit will current you how one can arrange Java on Ubuntu 24.04 LTS system step-by-step.
Java is a well-known platform neutral object-oriented programming language utilized in software program program development for a few years. It’s principally utilized in web development, mobile features, enterprise features and scientific computing.
Ubuntu 24.04 offers two important Java selections:
- OpenJDK: That’s the free and open-source implementation of Java, good for a lot of development needs.
- Oracle JDK: The official Java Enchancment Gear from Oracle, providing the entire Java experience with further choices.
On this submit, we’ll cowl every the alternatives.
Situations
- Pre-Arrange Ubuntu 24.04
- Native Shopper with admin rights
- Net Connectivity
Placing in OpenJDK on Ubuntu 24.04
OpenJDK bundle deal is on the market in default apt repositories of Ubuntu 24.04. So, its arrange is straight forward, open the terminal and run following apt directions.
$ sudo apt exchange $ sudo apt arrange default-jdk -y
Remember: default-jdk will arrange latest and safe OpenJDK mannequin (presently Java 21 LTS)
Verify Java Mannequin
$ java --version
In case you want to arrange explicit mannequin (e.g 11,17,21) of OpenJDK then run following.
$ sudo apt arrange openjdk-11-jdk $ sudo apt arrange openjdk-17-jdk
As quickly as OpenJDK-17 bundle deal is put in, chances are you’ll verify the Java mannequin by working following command:
$ java --version
Placing in Oracle Java (JDK) on Ubuntu 24.04
With a view to arrange Oracle JDK, first you may wish to receive its Debian bundle deal from its official web site on-line.
https://www.oracle.com/java/technologies/downloads/
At current Oracle Java 21 is the LTS mannequin, so select Java 21 Tab and click on on on Debian bundle deal to acquire Java 21 or copy the hyperlink.
We’re capable of moreover receive Oracle Java Debian bundle deal using beneath wget command,
$ wget https://receive.oracle.com/java/21/latest/jdk-21_linux-x64_bin.deb
As quickly because the bundle deal is downloaded, arrange it using beneath apt command.
$ sudo apt arrange ./jdk-21_linux-x64_bin.deb -y
Publish arrange, verify its mannequin, run
Configure Default Java
There is likely to be a state of affairs the place you would have put in a variety of variations of Java nevertheless want to set one explicit mannequin as default. Execute following command,
$ sudo update-alternatives --config java
Choose the Java mannequin by selecting its amount as confirmed beneath.
Set JAVA_HOME Setting Variable
To set the JAVA_HOME variable, first get completely the trail of Java, run
$ ls -l /usr/lib/jvm/ full 12 lrwxrwxrwx 1 root root 21 Apr 17 17:54 java-1.17.0-openjdk-amd64 -> java-17-openjdk-amd64 drwxr-xr-x 9 root root 4096 May 26 10:24 java-17-openjdk-amd64 drwxr-xr-x 9 10668 10668 4096 May 26 10:14 jdk-21-oracle-x64 drwxr-xr-x 2 root root 4096 May 26 10:24 openjdk-17 $
Subsequent, add the subsequent traces to /and so forth/setting file
$ sudo vi /and so forth/setting export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 export PATH="$PATH:${JAVA_HOME}/bin" $
Save and shut the file.
Now provide the setting file so that above variables come into the affect.
$ provide /and so forth/setting $ echo $JAVA_HOME
Wonderful, output above reveals that JAVA_HOME variable and its path has been configured effectively.
That’s all from this submit, we hope you would have found it informative and useful. Be joyful to submit your queries and recommendations in beneath suggestions half.
Thank you for being a valued member of the Nirantara family! We appreciate your continued support and trust in our apps.
- Nirantara Social - Stay connected with friends and loved ones. Download now: Nirantara Social
- Nirantara News - Get the latest news and updates on the go. Install the Nirantara News app: Nirantara News
- Nirantara Fashion - Discover the latest fashion trends and styles. Get the Nirantara Fashion app: Nirantara Fashion
- Nirantara TechBuzz - Stay up-to-date with the latest technology trends and news. Install the Nirantara TechBuzz app: Nirantara Fashion
- InfiniteTravelDeals24 - Find incredible travel deals and discounts. Install the InfiniteTravelDeals24 app: InfiniteTravelDeals24
If you haven't already, we encourage you to download and experience these fantastic apps. Stay connected, informed, stylish, and explore amazing travel offers with the Nirantara family!
Source link