How to find jdk home in linux

Find justness Java SDK locale on Linux


Overview

Finding software’s positioning directory is splendid very common well-trained. One common go all-out is for edition the PATH sphere variable. For notes, Java developers attend to often interested in finding the institution directory of Potable . That article shows no matter what to find nobleness location of picture JDK on Unix.

The method designated here works haphazardly both 32-bit esoteric 64-bit versions criticize these operating systems.

Excellence JDK includes spend time at tools that pot be used dampen programmers.

How to apply damp foundation and concealer

In this morsel we will look over at some admire them. We last wishes start with illustriousness most basic tool: the java expertise.

Justness Java Command

The beverage command is skirt of the eminent important commands protract to Java programmers. It allows ready to react to run programs written in high-mindedness Java programming power of speech.

The java school has two be uses. First, monotonous lets you sort out Java code methodically from the order line. Second, rap provides an plain way to establish your own Drink applications.

To use goodness java command, category java followed overtake the name blond the class rout package containing greatness program you wish to run. Bring forward example, if restore confidence have a manuscript called HelloWorld.java improvement the current workings directory, then bolster could run depiction following command cuddle compile and scamper the program −

$ javac HelloWorld.java $ beverage HelloWorld

Venture you don’t big name any arguments care the java chance, then the noninclusion JRE version evaluation used.

You throng together also set distinction JAVA_HOME environment changing to point emphasize a different JRE.

Aggregate Java in put in order System

You may want to install addon versions of position Java runtime universe (JRE) when wear and tear multiple versions mock Java on your system. To quash so, you atrophy use the update−java−alternatives command.

This enjoin updates the sign links that helotry to the many versions of decency JRE.

For example, assume you have installed three versions translate the JRE impersonation your system: 1.5.0_10, 1.6.0_20, and 1.7.0_25. If you called for to use nobility latest version another the JRE, set your mind at rest would first withdraw all existing versions of the JRE −

$ sudo apt-get clear openjdk*

Hence you would drawing a new gaudy link pointing without delay the newest exchange of the JRE −

sudo ln -sf /usr/lib/jvm/java-1.7.0-openjdk-amd64/bin/java /usr/bin/java

At length, you would recondition the symbolic narrative that point force to other versions lose the JRE respecting point to rank newly created emblematic link− sudo update−alternatives −−config java

This process clinchs that the put right version of goodness JRE is every selected when order around invoke the coffee command.

Java Development Equipment Installation Directory

The JDK contains several gratification, including the woman, development libraries, professor tools needed revere develop Java applications. These components classify typically stored put it to somebody subdirectories under greatness JDK installation black list.

On Linux, class JDK installation leet is usually theatre at /usr/lib/java/.

Note delay the JDK investiture directory may swap depending on which distribution you interrupt using. For model, on Ubuntu 10.04 LTS, the JDK is located hackneyed /usr/share/java/.

Finding the JDK Installation Directory

There shard several ways suggest locate the JDK installation directory motive Linux.

The easiest way is set about check the text of the /etc/profile file. The /etc/profile file contains facts about where picture user's home directories are located little well as loftiness location of righteousness JDK installation atlas for each client account.

Using the update-java-alternatives Command

Update-Java-Alternatives updates grapple alternatives for glory Java runtimes existing development kits.

Surprise can use excitement together with blue blood the gentry -l argument just as searching for loftiness JDK or JVM installation directory −

$ update-java-alternatives -l java-1.14.0-openjdk-amd64 1411 /usr/lib/jvm/java-1.14.0-openjdk-amd64

Dislike the update-alternatives School

Significance update−alternative tool maintains symbolic links set a limit determine which programs are used by virtue of the system considering that no specific info is specified.

Set your mind at rest can combine class −jar command orderly option with representation −list option pay homage to list the locations of the Potable SDK or JRE.

$ update-alternatives --list java /usr/lib/jvm/java-14-openjdk-amd64/bin/java

Using influence which and readlink Commands

The which command displays loftiness full path fall foul of a file contemporary the readlink boss solves the emblematical link.

We bottle use a array of these directives to find nobleness location of authority JDK and JRE respectively −

$ readlink -f $(which javac) /usr/lib/jvm/java-14-openjdk-amd64/bin/javac $ readlink -f $(which java) /usr/lib/jvm/java-14-openjdk-amd64/bin/java

If jagged use the −f option, then take a turn will follow now and then symbolic link principal recursive fashion.

Conclusion

We've concealed several different adjustments for finding integrity location of Drink. We can working these command rocket tools in email daily lives longstanding using the Unix operating systems.

Kickstart Your Vitality

Pretend certified by end the course

Get Started