How many java versions do i have installed on my Mac? - java

I'm a bit confused now. When I run the command java --version in the terminal i get: java 13.0.1. When I open the system preferences and click the java app and then about, i see it says Java version 8 1.8.0_231
Does that mean I have 8, 13 or both?
When I check through the java app.
When I check through the terminal.
When i check for all JDK installed on my system (only 1 version pop ups).

You can have multiple JDK installed in one machine but you can have only one version set as default Java SDK. Looks like you have Java 13 set as default.
Try running the following :
echo $JAVA_HOME
You can also go to the tab Java and see the list of all Java Runtime Environments (JRE.)
Please note that just because you have multiple JREs available doesnot mean all corresponding SDK are also there.

You can have many version of java on your Mac. But you can run only one of this in a process.
On my Mac, system preferences run with java path :
/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home/bin/java
But in terminal, this run with java path:
/usr/bin/java
I think you can replace java file in /usr/bin by another version java you want.

that means you jdk version is 13 , and your jre version is 1.8.
jre is used for running java apps ,and the jdk(java development kit) is for building apps with java language. java jdk is like the android sdk

Related

Can't download JDK 8

I'm trying to setup Unity to build for Android. But I can't get the Java Development Kit. Can't download it and can't find it either.
In this answer, the guy says
To ensure JDK is installed, just go through the following :
press Win + R
type 'cmd' in the popup and press button OK.
in the console which has opened, type javac -version and press enter.
You should see as an output :
javac 1.8.0_XX
If so SDK is installed.
I did that and I got "javac 1.8.0_XX", and so I assumed I had the JDK, so I went to Unity > External Tools > JDK and tried linking the following path: "C:\Program Files\Java\jre1.8.0", and got the error message: "The path you specified does not look like a valid JDK installation. Android development requires at least JDK(1.7), having JRE only is not enough. Please make sure you are selecting a suitable JDK home directory or download and install the latest JDK: link"
I clicked the download link for windows x64 and it never loads and eventually says there's no connection. I tried the x86 as well.
In this SO question How do I find where JDK is installed on my windows machine?
Answer: For windows, in the command prompt:
c:\> for %i in (java.exe) do #echo. %~$PATH:i
And so I did that and got the path "C:\ProgramData\Oracle\Java\javapath\java.exe"
When I try linking via Unity > External tools > JDK it doesn't find any files.
I'm a bit clueless now.
#RealAnyOne, you have installed Java with JRE only installation i.e., without out a JDK that’s what you see only one folder and this is why it also showing version in the command line since it won’t check for JDK. JRE is Java Runtime Environment, JDK is Java Development Kit which contains many essential libraries. So Ideally there should be two folders JRE and JDK. This is the reason you are getting this issue with Unity.
To Fix::
Uninstall old Java 8
Download Java 8 from the oracle website
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Install it. Now you should have two folders. Then point your Unity to it.

JavaVirtualMachines still says "1.6.0.jdk" after installing Java 7 JDK on OS X

I am trying to download the Java 7 jdk for Android Studio on my mac because "Android-21 requires compiling with JDK 7"
I have downloaded and installed the Java 7 jdk numerous times and restarted my laptop, but when I go to check the jdk in /System/Library/Java/JavaVirtualMachines it says 1.6.0.jdk
Correct me if I'm wrong, but 1.6.0 is the Java 6 jdk, right?
and is there a way to install it manually?
It is not in
/System/Library/Java/JavaVirtualMachines
But in
Library/Java/JavaVirtualMachines
If you take the folder structure at your root There will be two folders
1. System
2. Library
I am talking about the 2nd one. Not the Library folder in Systems folder
Use this command on terminal to find your JDK location
/usr/libexec/java_home
I have Java 7 on my Mac, but it's in /Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home.

How to check if Java 7 version is installed via Cocoa?

I have an Cocoa Xcode application that I am writing and I need to check what Java versions are installed on the user's machine. I know I can check /System/Library/Frameworks/JavaVM.framework/Versions/ and see what folders exist; however, this does not work for Java 7.
When I installed Java 7 on my Mac OS X 10.7.5, it was installed to /Library/Internet Plugins/JavaAppletPlugin.plugin. But this doesn't let me know the version of Java that is installed. If a newer version of Java is installed, I'm assuming it will install to the same place.
If I need to test if Java 7+ JRE is installed on the user's machine, should I just check if the file /Library/Internet Plugins/JavaAppletPlugin.plugin exists? Is there a better way to check?
Although you may have installed Java 7, you should have installed the Apple's Java Mac OS X 2012-006 update before. Having done that (and then installed java 7 again), java -version should tell you java version "1.7.x..."
Determining the Default Version of the JDK

mac replace java 6 with java 7 in /usr/bin/java

when I enter "whereis java" in terminal is says: /usr/bin/java
when I enter "java -version" it says "1.6.0_43" ...
when I open the Java control panel in system preference, the only version that i can see is Java 1.7.0_17 with the location at "/Library/Internet Plug-ins/JavaAppletPlugin.plugin/Contents/Home/bin/java". I don't have a "Java preference" panel that provides me to choose which version to use with some priority.
It is obvious that when internet browser is using, java 7 will be used and while I'm compiling Java in terminal Java 6 is used. But how could I get rid of Java 6? Is there a way that I could install Java 7 under /usr/bin/java?
BTW, I am not sure how to use the .profile file. Could i modify this file so that when I am in the terminal i can still use java 7?
Download Java SE 7u4 from Oracle.
Install it.
This version is different from the version downloaded while browsing the website.
It is really wired though...
In the meantime version 7u4 is no longer current and full of security holes!
My solution (which I got from the link provided in the comments) was to install the current Version of Java and start /Applications/Utilities/Java-Settings which displays the currently installed Java versions and allows to set the default version. Drag the current version to the top. Then /usr/bin/java pointed to the right version.

Compile Java 1.5 web app in Netbeans on Mac OSX 10.7.5

I am running Netbeans on my Mac OSX 10.7.5 which uses Java 1.6. I need to compile my web app in Netbeans against Java 1.5. I tried to install Java 1.5 on my Mac OSX, but it will not let you. How can I compile my netbeans web app against Java 1.5 on my mac osx?
Go to Tools -> Java Platforms. There, click on Add Platform, point it to YOUR_JDK_LOCATION. You can either set the another JDK version or remove existing versions.
after adding multiple platform change your project compile specification according to your requirement
To download jdk binary please visit below location
Link 1 zip file
Link 2 tar file
change your java version
$ export JAVA_HOME=/usr/libexec/java_home -v '1.5*'`
OR
parameterize the compiler like javac -source 1.5 -target 1.5
I believe I figured it out. In Netbeans, if you right click your project and go to 'Properties', in the 'Sources' category there is an option that says 'Source/Binary Format' which contains a drop down list where you can select the JDK version to build your project.
Since I am running JDK 6 on my mac, it will allow you to select version 6 and below, and in my case, I select version 5.

Categories

Resources