- What is path of JDK on Mac ? [duplicate]
- 5 Answers 5
- How to Find JAVA_HOME
- 1. Introduction
- 2. Windows-Specific Ways to Find JAVA_HOME
- 3. macOS and Linux-Specific Ways to Find JAVA_HOME
- 4. Using Java to Find JAVA_HOME
- 5. Conclusion
- How to Set JAVA_HOME on macOS
- Set JAVA_HOME Environment Variable
- Switch Between Java Versions
What is path of JDK on Mac ? [duplicate]
Im using Mac only at work and I need to set JAVA_HOME to proper path of JDK. I downloaded JDK, installed it and now I can’t find it anywhere. I was looking at the internet for the solution, but there is no folder Libraries/Java.
You should use /Library/Java/JavaVirtualMachines so IDEA picks up sources and javadoc properly. At the time of this writing, the correct path was /Library/Java/JavaVirtualMachines/1.6.0_22-b04-307.jdk/Contents/Home -stackoverflow.com/questions/470882/intellij-idea-setup-on-os-x
On Mac Sierra I’ve /Library/Java/JavaVirtualMachines which has jdk and System Preferences > Java what’s different between these 2 ?
This question has a really good 487-vote answer, stackoverflow.com/a/18144853/1099571, which is has a very interesting detail not found in any of the answers to stackoverflow.com/questions/6141180/… . I think it’s misleading to have a duplicate marker which says «This question already has an answer» over there; maybe that question should point here. Or, someone should make an answer with the best from both questions.
Use /usr/libexec/java_home -v 1.8 command on a terminal shell to figure out where is your Java 1.8 home directory. If you just want to find out the home directory of your most recent version of Java run /usr/libexec/java_home
5 Answers 5
The location has changed from Java 6 (provided by Apple) to Java 7 and onwards (provided by Oracle). The best generic way to find this out is to run
This is the natively supported way to find out both the path to the default Java installation as well as all alternative ones present.
If you check out its help text ( java_home -h ), you’ll see that you can use this command to reliably start a Java program on OS X ( java_home —exec . ), with the ability to explicitly specify the desired Java version and architecture, or even request the user to install it if missing.
A more pedestrian approach, but one which will help you trace specifically which Java installation the command java resolves into, goes like this:
/usr/bin/java -> /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home/bin/java
An important variation is the setup you get if you start by installing Apple’s Java and later install Oracle’s. In that case Step 2 above will give you
/usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Commands/java
and that particular java binary is a stub which will resolve the actual java command to call by consulting the JAVA_HOME environment variable and, if it’s not set or doesn’t point to a Java home directory, will fall back to calling java_home . It is important to have this in mind when debugging your setup.
How to Find JAVA_HOME
The Kubernetes ecosystem is huge and quite complex, so it’s easy to forget about costs when trying out all of the exciting tools.
To avoid overspending on your Kubernetes cluster, definitely have a look at the free K8s cost monitoring tool from the automation platform CAST AI. You can view your costs in real time, allocate them, calculate burn rates for projects, spot anomalies or spikes, and get insightful reports you can share with your team.
Connect your cluster and start monitoring your K8s costs right away:
We rely on other people’s code in our own work. Every day.
It might be the language you’re writing in, the framework you’re building on, or some esoteric piece of software that does one thing so well you never found the need to implement it yourself.
The problem is, of course, when things fall apart in production — debugging the implementation of a 3rd party library you have no intimate knowledge of is, to say the least, tricky.
Lightrun is a new kind of debugger.
It’s one geared specifically towards real-life production environments. Using Lightrun, you can drill down into running applications, including 3rd party dependencies, with real-time logs, snapshots, and metrics.
Learn more in this quick, 5-minute Lightrun tutorial:
Slow MySQL query performance is all too common. Of course it is. A good way to go is, naturally, a dedicated profiler that actually understands the ins and outs of MySQL.
The Jet Profiler was built for MySQL only, so it can do things like real-time query performance, focus on most used tables or most frequent queries, quickly identify performance issues and basically help you optimize your queries.
Critically, it has very minimal impact on your server’s performance, with most of the profiling work done separately — so it needs no server changes, agents or separate services.
Basically, you install the desktop application, connect to your MySQL server, hit the record button, and you’ll have results within minutes:
DbSchema is a super-flexible database designer, which can take you from designing the DB with your team all the way to safely deploying the schema.
The way it does all of that is by using a design model, a database-independent image of the schema, which can be shared in a team using GIT and compared or deployed on to any database.
And, of course, it can be heavily visual, allowing you to interact with the database using diagrams, visually compose queries, explore the data, generate random data, import data or build HTML5 database reports.
The Kubernetes ecosystem is huge and quite complex, so it’s easy to forget about costs when trying out all of the exciting tools.
To avoid overspending on your Kubernetes cluster, definitely have a look at the free K8s cost monitoring tool from the automation platform CAST AI. You can view your costs in real time, allocate them, calculate burn rates for projects, spot anomalies or spikes, and get insightful reports you can share with your team.
Connect your cluster and start monitoring your K8s costs right away:
We’re looking for a new Java technical editor to help review new articles for the site.
1. Introduction
In this quick tutorial, we’ll learn how to find JAVA_HOME on Windows, Mac, and Linux.
As we all know, JAVA_HOME is an environment variable that we commonly use to locate java executables, like java and javac.
2. Windows-Specific Ways to Find JAVA_HOME
If we’re using Windows as the operating system, first we need to open up our command line (cmd) and type:
If JAVA_HOME is defined in our environment, then the above command will print it out.
Or to show the location of the java executable, we can try:
3. macOS and Linux-Specific Ways to Find JAVA_HOME
If we’re using either macOS or Linux, we can open up our terminal and type:
If JAVA_HOME is defined in our environment, then the above command will print it out.
This probably just shows us /usr/bin/java, which really isn’t very helpful since it’s a symbolic link. To unravel this, we’ll use dirname and readlink.
dirname $(dirname $(readlink -f $(which javac)))
$(dirname $(readlink $(which javac)))/java_home
This command prints the currently used java folder.
4. Using Java to Find JAVA_HOME
If we’re able to run java ourselves, then we have a nearly platform-independent way as well:
java -XshowSettings:properties -version
Running this command outputs numerous properties, one of them being java.home.
To parse it though, we’ll still need a platform-specific tool.
For Linux and macOS, we’ll use grep:
java -XshowSettings:properties -version 2>&1 > /dev/null | grep 'java.home'
For Windows, we’ll use findstr:
java -XshowSettings:properties -version 2>&1 | findstr "java.home"
5. Conclusion
In this brief article, we learned how to find JAVA_HOME on different operating systems.
If this didn’t work though, it’s possible we didn’t set the JAVA_HOME variable properly while installing Java.
Slow MySQL query performance is all too common. Of course it is. A good way to go is, naturally, a dedicated profiler that actually understands the ins and outs of MySQL.
The Jet Profiler was built for MySQL only, so it can do things like real-time query performance, focus on most used tables or most frequent queries, quickly identify performance issues and basically help you optimize your queries.
Critically, it has very minimal impact on your server’s performance, with most of the profiling work done separately — so it needs no server changes, agents or separate services.
Basically, you install the desktop application, connect to your MySQL server, hit the record button, and you’ll have results within minutes:
How to Set JAVA_HOME on macOS
In this tutorial, I am going to share with you how to set the JAVA_HOME environment variable on a new macOS. The new way of setting JAVA_HOME environment variable allows us to dynamically identify and use the current Java version installed on a computer as well as let us switch between Java versions if there is more than one installed.
Starting from macOS 10.5 there is a very convenient command that we can use to identify the installed Java version. For example, open the terminal window on your Mac and type the following command to print out the top Java version installed on your Mac
If you have more than one version installed and you want to see all of the versions available, then run the following command in the terminal window.
To print the current Java version installed, simply use
Set JAVA_HOME Environment Variable
- Open the terminal windows and type:
This will open the .profile file for editing.
export JAVA_HOME=$(/usr/libexec/java_home)
Switch Between Java Versions
If you have more than one Java version installed on your computer and you need to switch to using a different version, you can do so by adding the -v flag.
Let’s have a look at a short example.
To learn what Java versions I have installed on my Mac computer I will type the following in the terminal window:
Matching Java Virtual Machines (2): 13.0.1, x86_64: "Java SE 13.0.1" /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home 1.8.0_231, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0_231.jdk/Contents/Home /Library/Java/JavaVirtualMachines/jdk-13.0.1.jdk/Contents/Home
Which tells that there are two Java versions installed and the top version is “jdk-13.0.1.jdk“.
- In the terminal window type
To open the .profile file for editing.
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8)
or if I wanted to set Java version 13, I would do it this way
export JAVA_HOME=$(/usr/libexec/java_home -v 13)
Now if you check Java version by typing
It should print the current Java version set in JAVA_HOME.
I hope this tutorial was helpful to you.