I have jdk1.7.0 directory in /usr/lib/jvm along with other open-jdk versions. I want my Ubuntu 12.04 to treat this jdk(jdk1.7.0) as its primary jdk i.e. I dont want to use open-jdks.
When I type java -version or javac -version, both the times it returns that it is using openjdk and its jre. How can change it to jdk1.7.0?
Put something similar to following to your ~/.bashrc
export JAVA_HOME="/usr/lib/jvm/jdk1.7.0"
export PATH="$JAVA_HOME/bin:$PATH"
for loading the changes, you can just run new bash by typing "bash" :]
Change the PATH variable so that /usr/lib/jvm is listed before the directory which contains Open JDK. If you are using bash, you can do this in the .bashrc file in your home directory.
Related
I had recently installed java 11 and set all the necessary paths in the system environment variables.
why does my java -version show the old java installed. Do i need to do something else to get his updated.
You need to add %JAVA_HOME%\bin to your path.
I have noticed that older Java versions put a copy of java.exe and javaw.exe in a directory and reference it from there. That directory, I think, does not contain javac.exe so javac -version is fine but java -version is not fine.
So, java -version is still referring to old java.exe which is there somewhere in your file system.
Do "where java.exe" on command prompt to find where you have java.exe.
Then delete the older versions of java.exe and javaw.exe. Then try doing java -version again.
It is worked for me:
Steps:
You need to add %JAVA_HOME%\bin to your path
Do "where java.exe" on Command Prompt to find where you have java.exe
Then delete the older versions of java.exe and javaw.exe. Then try doing java -ve2sion again.
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
I have researched this and none of the solutions that I have seen have fixed my error.
What is happening is I tried to install Java EE version got the above error and then found out that I must install Java SE first. So I installed Java SE and set the JAVA_HOME variable to C:\Program Files\Java\jdk1.8.0 which is where I installed my JDK. I also put C:\Program Files\Java\jdk1.8.0\bin in my PATH variable. Still not working. I also tried the JAVA_HOME variable with C:\Program Files\Java\jdk1.8.0\bin and that didn't work. I also tried installing without the PATH variable being updated to where I put my JDK.
I'm really getting confused as to why this is happening. I've had Java before and I don't recall having this much trouble installing it.
PS I don't install from the command line I just click the download icon in Firefox and then click the download.
Try running the installer at your commandline and pass the path of the JRE instead of the JDK.
For Example:
java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre8"
I had the exact same problem and even downloading the version without JDK didn't help!
I simply installed it from the terminal with passing the JRE For Example:
java_ee_sdk7-windows.exe -j "C:\Program Files\Java\jre7"
and it worked like a charm!
I had the same problem but an additional step was required in order to install using the command line. In the command window (on my Windows 10 laptop) I had to use:
cmd /d
to tell the cmd window to ignore registry AutoRun commands before the java installation executable would run. After using cmd /d, and changing to the directory where the .exe file was at, the following worked:
java_ee_sdk-6u4-jdk7-windows-x64.exe -j "%JAVA_HOME%"
Where JAVA_HOME is a system environment variable pointing to an existing JDK installation (C:\Program Files\Java\jdk1.8.0_65).
Uninstall everything, all of it.
Then go to your Program Files folder (and (x86) folder if on a 64bit Windows) and physically remove any Java folders.
Reinstall Java SE and then the EE packages. Sometimes Windows appears to get a bit confused and you need to help it figure out what to do.
If you want to uninstall, go to the glassfish folder and open the command prompt, then type:
uninstall.exe -j <The path to your JRE>
These points may be helpful.
java EE SDK7 contains glassfish v4.0 and it compatible with JDK6 and JDK7.
java EE SDK8 contains glassfish v5.0, it compatible with only JDK7 and JDK8, not JDK 9 or beyond.
So environment variable JAVA_HOME has to point to the root directory of one of the mentioned JDK. and %JAVA_HOME%\bin should be added to environment variable path
Despite having followed all of the above, setup of java EE SDK7 gets error:
could not find the required version of the Java(TM;
as Bakudan and laf8 said,
open cmd using run, with /d /a options as followed.
cmd /d /a
and next run SDK7-setup with -j option like this command
sdk7.exe -j "%JAVA_HOME%"
note that %JAVA_HOME% enclosed BY ""
This was happening to me when I tried to run the Java EE installer. What I did, was to download from Oracle a Java EE version which didn't include the JDK, because it was already installed in my system. Problem solved!
Open regedit.
goto :HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\
set CurrentVersion to desired JDK version.
Check JavaHome and RuntimeLib path's for selected jdk version folder
Check JavaHome and RuntimeLib path's for selected jdk version folder
example: "HKEY_LOCAL_MACHINE\Software\JavaSoft\Java Runtime Environment\1.7".
example:
JavaHome=C:\Program Files (x86)\Java\jdk1.7.0_79
RuntimeLib=C:\Program Files (x86)\Java\jdk1.7.0_79\jre\bin\server\jvm.dll
Source: http://tech-read.com/2009/05/19/how-to-solve-error-could-not-find-java-runtime-2-environment-while-opening-an-ide/
I have openjdk and the sun version installed, how do i choose the sun version via command line?
I want this for eclipse ptp.
Just explicitly call the right java executable in your command line.
i.e. <path to sun java>\java -jar test.jar
You can do two things if you want to start Eclipse in Sun Java.
Change your PATH variable to have the Sun Java Bin Directory before Open JDK.
export PATH=Path_to_Sun_Java/bin:$PATH
And then start eclipse from the same terminal which will use Sun Java
Edit the eclipse.ini file and specify the -vm option
-vm Path_to_Sun_Java/bin/java
For Eclipse you can start it with the -vm path_to_vm/bin/java option.
If you want to set it for the system, that depends on your OS. Most Linux distributions have a tool that switches system VMs for your (sets PATH and JAVA_HOME accordingly). Maybe setting both in your ˜/.profile on Linux or user environment variable on Windows is already good enough for your purposes?
You can try this script which makes everything for you or follow steps manually with nice explanation.
if for eclipse only but for all eclipse Projects then :
from the dropdown menu window->preferences, then java->installed jre, select your jre, if not there, just browse your system and locate the path to Oracle JRE/JDK
, if for all your OS, here links for linux:
Suse Linux:
http://www.freetechie.com/blog/installing-oracle-sun-java-jrejdk-1-7-update-7-on-opensuse-12-2-x86_64/
Ubuntu:
http://www.webupd8.org/2012/01/install-oracle-java-jdk-7-in-ubuntu-via.html
I have 2 java versions on my computer:
/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
The 1.6.0 is set to default. How can I make my java programs to run 1.7?
Tried to add:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
to my .zshrc file. But this seems to only change the path for my terminals java command.
Also tried to change the HOME symlink like this:
cd /Library/Java
mv Home Home-1.6
ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/ Home
This had no effect at all.
Also tried java changer software:
http://www.guigarage.com/2013/02/change-java-version-on-mac-os/
But no effect.
Any idea how to start java programs like .app and .jar files with the 1.7 version by just clicking on them?
I believe OS X (at least 10.8) uses the following paths:
JRE: /System/Library/Frameworks/JavaVM.framework/Versions/Current
JDK: /System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK
Those are symlinks, which you can update to point to your 1.7 installation.
You can verify this fairly easily:
a) run which java to check which java executable is being executed. In theory, that should be /usr/bin/java.
b) run ls -la on your java executable, which should tell you where it points (/System/Library/Frameworks/JavaVM.framework/Versions/Current/Commands/java
on my machine).
I think this should sort your .jar execution issue. If your Java application is wrapped in a .app, I believe it's a bit more complex: if memory serves, the version of java used will depend on the JavaApplicationStub being used by the .app.
$ edit ~/.profile
#Java 1.8
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
export PATH=${PATH}:${JAVA_HOME}
$ java -version
java version "1.8.0_20-ea"
here are the steps:
http://ukitech.blogspot.com/2014/04/switching-version-of-java-on-mac.html
You can always add into your profile both on Mac or Linux. Just create if doesn't exist ~/.profile file and there this line:
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home
This should work .zshrc as well as .bash_profile are loaded only when terminal window is openned and profile when your graphical environment starts up.