update java compiler on mac os - java

I I donwloaded the last mac os JDK (jdk-8u5-macosx-x64) from the oracle website and install it sucsefully. Reboot the laptop but my java compiler version still the same
javac -version
javac 1.6.0_51
Edit
I just changed the Java_Home variable in ~/.bash_profile to the new one /Library/Java/JavaVirtualMachines/jdk1.8.0_05.jdk/Contents/Home. It works perfectly

Uninstall the current JDK and install jdk-8u5 again.
You can uninstall it using the following:
To uninstall the JDK, you must have Administrator privileges and execute the remove command either as root or by using the sudo(8) tool.
Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format:
/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk
For example, to uninstall 8u6:
% rm -rf jdk1.8.0_06.jdk
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
Taken from http://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html#A10969

Related

How to uninstall JDK on Mac OS?

Folks - I am facing challenges while trying to uninstall JDK from my MAC (macOS High Sierra Version 10.13.4 - 17E199). I have two JDK instances installed and I want to uninstall both of them.
I am following the steps listed on this page: https://docs.oracle.com/javase/8/docs/technotes/guides/install/mac_jdk.html
I am trying to run this command in the /Library/Java/JavaVirtualMachines directory which throws an error that I do not have the permission.
rm -rf jdk1.8.0_06.jdk
I am the administrator of the machine and am not sure what more permission do I need. I have made attempts as the admistrator and as the root user with no success.
Please share your thoughts on this.
From the official Oracle manual.
Navigate to /Library/Java/JavaVirtualMachines and remove the directory whose name matches the following format:
/Library/Java/JavaVirtualMachines/jdkmajor.minor.macro[_update].jdk
For example, to uninstall 8u6:
%rm -rf jdk1.8.0_06.jdk
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
To remove system files you need to add sudo before rm -rf command.
For MacOS - Big Sur | Using Terminal
I was able to remove OpenJDK as per information provided in below link.
Site Link
If you want to remove JDK from mac you can use the following command:
cd /Library/Java/JavaVirtualMachines/
and then use sudo to remove the jdk because you need root permissions to delete jdk from /Library/Java/JavaVirtualMachines/.
/Library/Java/JavaVirtualMachines/ is owned by root.
sudo rm -rf jdk1.8.0_06.jdk
https://installvirtual.com/uninstall-java-8-mac-os-x/
This answer is correct for JDK 8, but it would be nice to point out that Oracle provides different instructions for each release of the JDK. The link structure changes slightly for some versions, but generally you can go to https://docs.oracle.com/en/java/javase, select your JDK release, and look for the "Install Guide" link in the Overview group.
For example:
JDK 9
JDK 10
JDK 11
Also, the files in /usr/bin are not part of the JDK, so you don't really want to remove them. On a system that has never had the JDK installed:
$ ls -l /usr/bin/java
lrwxr-xr-x 1 root wheel 74 Sep 27 17:08 /usr/bin/java -> /System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
$ java -version
No Java runtime present, requesting install.
Apparently macOS includes a baseline version of the JDK, where each command is a stub that just prints this message and pops up a dialog in the GUI.

How to uninstall Java 9 on macOS Sierra

I'm having trouble removing Java 9 from my macOS Sierra system.
I accidentally installed Java 9, instead of Java 8, so now all my Eclipse projects give me these warnings: Build path specifies execution environment JavaSE-1.8. There are no JREs installed in the workspace that are strictly compatible with this environment.
I have used the following guide, but it did not work. Here is my command output when running java -version from the command line:
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
for macOS high sierra removing java 9:
delete the java folder you find in the dir shown to you after executing:
/usr/libexec/java_home -V
use "Go to" in finder and copy and paste the dir to get there
There are two commands which are very simple and useful. If you want to keep multiple versions simply set JAVA_HOME to version you want to use.
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_(version you want to use).jdk/Contents/Home
Example--> export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_161.jdk/Contents/Home
Else in addition to above command remove/uninstall additional jdk version from your system with below command.
sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-(version you want to remove).jdk/
Example --> sudo rm -rf /Library/Java/JavaVirtualMachines/jdk-9.0.4.jdk/
Please refer below github link for additional details -->
https://gist.github.com/schnell18/bcb9833f725be22f6acd01f94b486392
Thanks
On MacOS you can list what JDKs you have installed and where they are installed to with:
/usr/libexec/java_home -V
If you want to select one of the installed JDKs to be used as default, you can do:
/usr/libexec/java_home -v 1.8
Verify which is now default with java -version.
You can manually add the location of other installed JREs in Eclipse via Preferences / Java / Installed JREs , press Add, and then point it to one of the locations should with the -V option above. You can then check it to select which is default for your projects.
After viewing which Java Virtual Machines I had on my computer using the following command:
ls /Library/Java/JavaVirtualMachines
I realized no additional JDK's would appear after using the Java 8 installer (besides Java 9). When doing further research, it turns out I had installed the other version that is not a SE development kit and it was just working in web browsers, not for the terminal.
For anyone having the same issue, make sure you use the Java SE Development Kit 8.
Uninstall Oracle Java using the Terminal:
Note: To uninstall Java, you must have Administrator privileges and execute the remove command either as root or by using the sudo tool.
Remove one directory and one file (a symlink), as follows:
Click on the Finder icon located in your dock
Click on the Utilities folder
Double-click on the Terminal icon
In the Terminal window Copy and Paste the commands below:
sudo rm -fr /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin
sudo rm -fr /Library/PreferencePanes/JavaControlPanel.prefPane
sudo rm -fr ~/Library/Application\ Support/Java
Do not attempt to uninstall Java by removing the Java tools from /usr/bin. This directory is part of the system software and any changes will be reset by Apple the next time you perform an update of the OS.
Source:https://www.java.com/en/
I believe the problem is navigating to the correct directory... Once you are where you are supposed to be you can run the sudo commands to remove whichever versions of java you want to remove.
First, run the command in the terminal to determine which version of Java you are running,
java -version
then you can navigate to pesky version of java that you intend to delete by using the following command:
cd /Library/Java/JavaVirtualMachines
then once you see are in the JavaVirtualMachines path, type in ls to see what versions of Java you have installed,
ls
and finally when you know which version or versions of Java you want to uninstall:
sudo rm -rf jdk-10.0.1.jdk #or whichever version you want to delete
I know that you've asked about how to uninstall the java version. But, I think it's important how to manage your Java version in a very good way.
For me, the best way is using SDKMan, a very nice tool for managing you Development tools like Java.
Here you can learn more about it: http://sdkman.io/
You can install your Java version as follow:
$ sdk install java
You can install others tools like Scala:
$ sdk install scala 2.12.1
Uninstall your tools very easy:
$ sdk uninstall java 9
And so on. Hope this helps you in future installation of your development tools.

Running web project on HTTP Preview give error: "Could not find JRE executable" on MAC OS X Yosemite

I am trying to run Eclipse Mars on Mac. Java 8 is installed. (JDK and JRE)
Running web project on HTTP Preview gives error that Could not find JRE executable.
In Eclipse>Prefrences>Java>Installed JREs when I try to search the JRE in /System/Library/Frameworks/JavaVM.framework/Version , I am not able to find any versions inside.
Any solution?
Given, that you installed Oracle Java (JDK) 8, open a Terminal and:
sudo rm /Library/Java/Home
which removes old links first. Note: This step might be optional.
Second step (Note: replace XX first!):
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_XX.jdk/Contents/Home /Library/Java/Home
This command recreates a symbolic link to the actual Java 8 installation folder.
Afterwards, a fresh installation of Eclipse should detect Java8 in your system and should work with this version out of the box. You can modify an installed Eclipse to use this installation by navigating in Eclipse to:
Preferences -> Java -> Installed JREs.
Finally, remove the old JRE/JDK entries AND add a new one for the path (see above) with the name Java8.
Additionally, you can create or edit a file .bash_profile (in the directory of your user home) and put the following snippet there:
export JAVA_HOME=/usr/libexec/java_home -v 1.8
Save that file and reopen a Terminal instance. If you execute export as a command there, you should see a valid JAVA_HOME with the location of your JDK 8 installation. Restart your IDE afterwards.

How do I install an earlier version of Java SDK on OSX

I have the Java 1.8.0_45 SDK installed on OSX Yosemite (10.10.4), but because of a bug in this release I need to go back to 1.8.0_25
I have downloaded and installed the earlier version (1.8.0_25) but even after a reboot java -versionstill shows 1.8.0_45.
I don't really understand where Java resides on OSX, but how can I get my system back so it uses 1.8.0_25
Try and add this to your ~/.bashrc
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
You can have multiple JRE/JDK's installed, by changing this path, you can specify which one you use each time you open a new shell.
Here is what I use in my .bashrc
JAVA_VERSION=7
JAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home
JAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_40.jdk/Contents/Home
tmp="JAVA_${JAVA_VERSION}_HOME"
export JAVA_HOME=${!tmp}
export PATH=${!j}/bin:$PATH
Here, you can simply change the 7 to an 8.
This will change the JAVA_HOME, and append the bin directory to your path for general use from the command line.
note you may beed to change your java home's according to the specific release versions installed on your machine.
Ah found it, suprisingly easy:
macbook:JavaVirtualMachines paul$ cd /Library/Java/JavaVirtualMachines
macbook:JavaVirtualMachines paul$ ls
jdk1.7.0_40.jdk jdk1.7.0_45.jdk jdk1.8.0.jdk jdk1.8.0_05.jdk jdk1.8.0_20.jdk jdk1.8.0_25.jdk jdk1.8.0_45.jdk
macbook:JavaVirtualMachines paul$ sudo rm -fr jdk1.8.0_45

Get Oracle Java 1.8 in windows without installing it

Is it possible to get Java in zip format? I don't want to install it by getting .exe file.
Is there any zip version of Java 1.8 so that I can download it and extract it and start using it in my Windows machine (64-bit processor)?
You can extract the JDK folder from the Installation EXE.
Check this link for the steps. The post was for JDK 1.7 it will work for JDK 1.8 also
Do the following.
Steps
Download JDK from Oracle
Download and Install 7-zip from here
Open installition exe using 7-Zip
Extract the tools.zip
Extract the content of tools.zip to a folder (e.g. c:\jdk).
Open the extracted folder in cmd prompt.
Execute for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar" command
Set JAVA_HOME to the jdk (e.g c:\jdk) folder.
Add %JAVA_HOME%/bin to the PATH env variable.
Testing
Run the following command to check the installation, it will print the version of JDK.
c:> javac -version
javac 1.7.0_51
NOTE: Tested with JDK 1.7 and 1.8
Update 1
Edited the answer to add the steps in the answer itself instead of the link to a blog post.
Update 2
For 64-Bit please check unpack-jdk-x64.bat by grabantot
I was looking for a solution to this as well. I'm not sure why the OP wanted to do this. I'm just trying to get a newer version of java for new development while not interfering with an older Java install which a legacy application requires (I'd like to update the legacy app, but it's not an option, now)
I think the hack I am going to try is this:
Install 1.8
Take a copy of the install folder
Uninstall 1.8
Reinstall / Repair 1.7
restore the copy of 1.
I'm sure if I had a better understanding of what the install is doing, this would not be necessary.
I had a spare virtual machine hanging around (if not you could build one or maybe even download one) so I:
installed the Oracle JDK in the guest
copied the jdk folder from the guest to the host
added a JAVA_HOME environment variable.
The operating systems obviously have to be close (not sure how close, I used Windows Server 2008 64 bit guest on a Windows 10 64 bit host and it seemed to work).
Was a quick fix for me as I didn't want a full install and wanted to remove it afterwards.
If you do not have permission to unzip zip file then you cannot install java .
As java does not need installation for running . You just need to give path of java.exe where it is located .
In Windows it is located in C:\Program Files\Java\jdk1.8.0_05\bin
For a solution you can run installer on any machine that you have permission and just copy and paste the folder of java to anywhere in your system (Machine where you have administrative rights problem) . and just set the path as by opening command prompt as set path="C:\Program Files\Java\jdk1.8.0_05\bin"
java will be working as you want
The following worked for me (I had JDK 1.8 installed and needed the 32 bit version as well):
Verify the current version with java -version
Assuming a different version (minor or major is being installed), download the relevant JDK installable from Oracle and run it. In the
first dialog, specify a different folder than the default location
(might work with the default one as well), then select Next. It will
extract the files there in this folder, then it will asl for the
folder where the JRE is to be installed. Simply close the installer,
now you should have just the JDK in the specified folder.
Rerun java -version, it should give you the same version as earlier.
Worst case, if it shows the newer version, go to your system path (Right click My Computer (or This PC) -> Properties -> Advanced
system settings -> Advanced tab -> click on Environment variables
button) and remove the Oracle javapath entry (From the Path variable
in the bottom part of the window). The add the older java version's
bin folder to the path variable in the beginning.
for /r %x in (*.pack) do .\bin\unpack200 -r "%x" "%~dx%~px%~nx.jar"
Is this working for linux shell scripting , I got syntax error for the above.

Categories

Resources