Related
I currently have CDH 5 installed on CentOS 6.5 with java jdk1.7 and I am trying to get CDH to use jdk1.8.
I do know that Java 1.8 is not a recommended version of CDH, but it is only a test cluster, so it isn't a big deal.
I have installed both Java 1.7 and Java 1.8 from Oracle's website using the RPM installation, so both versions of Java are currently under /usr/java. Using ls -ld my Java directory looks like:
/usr/java/default -> /usr/java/latest
/usr/java/jdk1.7.0_75
/usr/java/jdk1.8.0_31
/usr/java/latest -> /usr/java/jdk1.8.0_31
I also have script set up in /etc/profile.d to set $JAVA_HOME to /usr/java/default. The contents of my profile.d script:
export JAVA_HOME=/usr/java/default
export PATH=${JAVA_HOME}/bin:${PATH}
So when felt that I have this right, I run:
$ which java
/usr/java/default/bin/java
Telling me that it is pointing to the version of Java symlinked in default. And to determine which version of java is running, I run:
$ java -version
java version "1.8.0_31"
Java(TM) SE Runtime Environment (build 1.8.0_31-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.31-b07, mixed mode)
And I can see that I have Java 1.8 currently running.
Everything seems great, except when I try to start a Hadoop service. The easiest to start is ZooKeeper, because it only has one service. HDFS has multiple servers so it is more work that to just start and stop ZooKeeper.
Starting ZooKeeper is done with the following command:
$ sudo service zookeeper-server start
Then to check which version of java it is running, I search the running processes list for java:
$ ps -ef | grep java
495 7170 1 7 12:27 ? 00:00:00 /usr/java/jdk1.7.0_75/bin/java -Dzookeeper.datadir.autocreate=false -Dzookeeper.log.dir=/var/log/zookeeper -Dzookeeper.root.logger=INFO,ROLLINGFILE -cp /usr/lib/zookeeper/bin/../build/classes:/usr/lib/zookeeper/bin/../build/lib/*.jar:/usr/lib/zookeeper/bin/../lib/slf4j-log4j12.jar:/usr/lib/zookeeper/bin/../lib/slf4j-log4j12-1.7.5.jar:/usr/lib/zookeeper/bin/../lib/slf4j-api-1.7.5.jar:/usr/lib/zookeeper/bin/../lib/netty-3.2.2.Final.jar:/usr/lib/zookeeper/bin/../lib/log4j-1.2.16.jar:/usr/lib/zookeeper/bin/../lib/jline-0.9.94.jar:/usr/lib/zookeeper/bin/../zookeeper-3.4.5-cdh5.3.0.jar:/usr/lib/zookeeper/bin/../src/java/lib/*.jar:/etc/zookeeper/conf::/etc/zookeeper/conf:/usr/lib/zookeeper/*:/usr/lib/zookeeper/lib/* -Dzookeeper.log.threshold=INFO -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.local.only=false org.apache.zookeeper.server.quorum.QuorumPeerMain /etc/zookeeper/conf/zoo.cfg
I know that runs off the screen, bu the important part is that Zookeeper is being started by /usr/java/jdk1.7.0_75/bin/java.
To fix this, I have tried a few things:
Looking at the conf files for Hadoop and ZooKeeper under /etc/hadoop/conf and /etc/zookeeper/conf, respectively.
I found nothing setting JAVA_HOME.
Looking at the /usr/bin/zookeeper script to see if JAVA_HOME was set elsewhere,
I did find the script /usr/lib/bigtop-utils/bigtop-detect-javahome has the ability to set JAVA_HOME, but my profile.d script overrides that.
Manually moving /usr/java/jdk1.7 to /tmp.
Sadly, this is the only thing that works. When I move the jdk1.7 dir to another directory, and start ZooKeeper, it will use Java 1.8. Moving the jdk1.7 dir back, reverts to ZooKeeper using Java 1.7.
Has anyone dealt with this problem and does anyone know how to deal with this? I feel that I have Java set up correctly, but something is telling ZooKeeper/Hadoop to use an old version of Java?
I came here because I was looking for ways to upgrade JDK from 1.7 to 1.8 on the latest Coudera QuickStart VM 5.8 (can't believe they still ship it with JDK1.7 by default!). The hints and suggestions in the above answers helped tremendously - but since they were not listing complete steps to achieve the upgrade - I thought I would add that to help others like me.
So, here is a complete set of steps to upgrade Cloudera QuickStart VM from JDK1.7 to 1.8:
check your current JDK version - out-of-the-box it is:
[cloudera#quickstart ~]$ java -version
java version "1.7.0_67"
Java(TM) SE Runtime Environment (build 1.7.0_67-b01)
Java HotSpot(TM) 64-Bit Server VM (build 24.65-b04, mixed mode)
download desired version of JDK1.8.xx - in my case: jdk-8u111-linux-x64.tar.gz
as user 'cloudera':
untar and move the resulting jdk1.8.0_111 dir to the /usr/java dir:
tar xzf jdk-8u111-linux-x64.tar.gz
sudo mv -f jdk1.8.0_111 /usr/java
shutdown all Hadoop services:
$ for x in `cd /etc/init.d ; ls hadoop-*` ; do sudo service $x stop ; done
update bigtop-utils file - set JAVA_HOME to your new JDK:
sudo vi /etc/default/bigtop-utils
updated lines:
# Override JAVA_HOME detection for all bigtop packages
export JAVA_HOME=/usr/java/jdk1.8.0_111
update 'cloudera' user's .bash_profile - export JAVA_HOME and add update PATH:
export JAVA_HOME=/usr/java/jdk1.8.0_111
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin
export PATH
restart your VM
check Java version - should be the 1.8 one now:
[cloudera#quickstart ~]$ java -version
java version "1.8.0_111"
Java(TM) SE Runtime Environment (build 1.8.0_111-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.111-b14, mixed mode)
By the way, I did not setup the /usr/java/default with the 'latest' sym link as #milk3422 did, for the sake of simplicity, but it would have worked just as well.
thanks!
I hate to answer my own questions, but here is the answer:
The wrong version of $JAVA_HOME is getting set for 2 reasons:
Using the command service removes most environmental variables. From man service:
service runs a System V init script in as predictable environment as
possible, removing most environment variables and with current work-
ing directory set to /.
The /usr/lib/bigtop-utils/bigtop-detect-javahome script has the ability to be configured with the environment variable BIGTOP_JAVA_MAJOR to manually set which version of Java to use. I tried setting this as an environment variable, but service removes it :(. It is also important to note that this script will find all versions of java installed, but the order of preference is Java 6, Java 7, Java 8, Open Java. So if you have Java 6, and 8 installed, it will prefer 6 over 8.
In short, to fix my problem, I added the following to the top of /usr/lib/bigtop-utils/bigtop-detect-javahome:
BIGTOP_JAVA_MAJOR=8
You can also set JAVA_HOME in this file to specify a specific version or path.
I had the same problem. I set
JAVA_HOME=... below the file /usr/lib/bigtop-utils/bigtop-detect-javahome
to override the default detect value. That works great!
Java is configurable in the web UI. Open Cloudera Manger --> Hosts --> Configurations --> Advanced, then set the JAVA HOME. This overrides the CDH's Java detection mechanism.
I have downloaded java8 and then created a folder "java" in "/usr/local". Later I set the JAVA_HOME and PATH using export.
echo $JAVA_HOME output /usr/local/java/jdk1.8.0_20
Now, when I open terminal and type java -version it prompts to choose any package from below to install java. But when I do $JAVA_HOME/bin/java -version it gives
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)
and when I run
sh /home/SOAPUI_HOME/soapui-4.0.1/bin/soapui.sh gives
================================
=
= SOAPUI_HOME = /home/SOAPUI_HOME/soapui-4.0.1
=
================================
/home/SOAPUI_HOME/soapui-4.0.1/bin/soapui.sh: 141: /home/SOAPUI_HOME/soapui-4.0.1/bin/soapui.sh: java: not found
SoapUI doesn't use JAVA_HOME in its launcher .sh files. You could add /usr/local/java/jdk1.8.0_20/ before java on line 141 (if you are using SoapUI 4.0.1, but I would suggest to upgrade to 5.0.0, then it's line 72).
Another solution would be to to make sure your java installation is the PATH variable.
Third, and easiest in my opinion, is to download the installer version of SoapUI. It is a .sh file which installs both SoapUI and Java.
I turned off the Internet Connection, because in the logs I saw many HttpConnection errors. Launch SOAP UI from terminal
sh /Applications/SoapUI-5.1.3.app/Contents/java/app/bin/soapui.sh
and then turn on the internet again.
When I want my systems Java version to overrule the SoapUI Java version, I rename the jre folder within the soapUI folder to temp or whatever. After that SoapUI picks up the Java version that you are running on your system.
(Wasn't sure if this should go on SU... migration is certainly an option, but more programmers read questions here, so here goes).
I am running Mac OS X 10.8.4, and I have Apple's JDK 1.6.0_51 installed as well as Oracle's JDK 1.7.0_25. I recently installed Oracle's 1.8 preview JDK for some pre-release software that requires it. Now, when I run /usr/libexec/java_home, I get this:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (4):
1.8.0, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
1.7.0_25, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_25.jdk/Contents/Home
1.6.0_51-b11-457, x86_64: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
1.6.0_51-b11-457, i386: "Java SE 6" /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
Great.
However, running:
$ java -version
Returns:
java version "1.8.0-ea"
That means that the default version of Java is currently the pre-release version, which breaks some "normal" packages (in my case, VisualVM).
I can't set JAVA_HOME because launching applications ignores environment variables, even when launching from the command line (e.g. $ open /Applications/VisualVM.app).
So, is there a file I can edit where I can set my JVM ordering preferences globally?
(Please don't tell me to launch the Java Preferences Panel because that simply does not work: it does not contain anything useful and only lists one of the 4 JVMs that I have installed.)
Update:
Oracle JVMs live in /Library/Java/JavaVirtualMachines. Re-naming the JDK 1.8 directory to jdk1.8.0.jvm.xyz does not change anything: java_home still finds it in the right place, and running /usr/bin/java still executes the 1.8 JVM. This is not an issue with synlinks, etc.
Answers to Similar Questions
While this answer offers what amounts to a hack that will remove versions of Java from being picked up by java_home, it still does not answer this question of how java_home chooses its default and whether or not users can non-destructively set it.
I think JAVA_HOME is the best you can do. The command-line tools like java and javac will respect that environment variable, you can use /usr/libexec/java_home -v '1.7*' to give you a suitable value to put into JAVA_HOME in order to make command line tools use Java 7.
export JAVA_HOME="`/usr/libexec/java_home -v '1.7*'`"
But standard double-clickable application bundles don't use JDKs installed under /Library/Java at all. Old-style .app bundles using Apple's JavaApplicationStub will use Apple Java 6 from /System/Library/Frameworks, and new-style ones built with AppBundler without a bundled JRE will use the "public" JRE in /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home - that's hard-coded in the stub code and can't be changed, and you can't have two different public JREs installed at the same time.
Edit: I've had a look at VisualVM specifically, assuming you're using the "application bundle" version from the download page, and this particular app is not an AppBundler application, instead its main executable is a shell script that calls a number of other shell scripts and reads various configuration files. It defaults to picking the newest JDK from /Library/Java as long as that is 7u10 or later, or uses Java 6 if your Java 7 installation is update 9 or earlier. But unravelling the logic in the shell scripts it looks to me like you can specify a particular JDK using a configuration file.
Create a text file ~/Library/Application Support/VisualVM/1.3.6/etc/visualvm.conf (replace 1.3.6 with whatever version of VisualVM you're using) containing the line
visualvm_jdkhome="`/usr/libexec/java_home -v '1.7*'`"
and this will force it to choose Java 7 instead of 8.
I've been there too and searched everywhere how /usr/libexec/java_home works but I couldn't find any information on how it determines the available Java Virtual Machines it lists.
I've experimented a bit and I think it simply executes a ls /Library/Java/JavaVirtualMachines and then inspects the ./<version>/Contents/Info.plist of all runtimes it finds there.
It then sorts them descending by the key JVMVersion contained in the Info.plist and by default it uses the first entry as its default JVM.
I think the only thing we might do is to change the plist: sudo vi /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Info.plist and then modify the JVMVersion from 1.8.0 to something else that makes it sort it to the bottom instead of the top, like !1.8.0.
Something like:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
...
<dict>
...
<key>JVMVersion</key>
<string>!1.8.0</string> <!-- changed from '1.8.0' to '!1.8.0' -->`
and then it magically disappears from the top of the list:
/usr/libexec/java_home -verbose
Matching Java Virtual Machines (3):
1.7.0_45, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_45.jdk/Contents/Home
1.7.0_09, x86_64: "Java SE 7" /Library/Java/JavaVirtualMachines/jdk1.7.0_09.jdk/Contents/Home
!1.8.0, x86_64: "Java SE 8" /Library/Java/JavaVirtualMachines/jdk1.8.0.jdk/Contents/Home
Now you will need to logout/login and then:
java -version
java version "1.7.0_45"
:-)
Of course I have no idea if something else breaks now or if the 1.8.0-ea version of java still works correctly.
You probably should not do any of this but instead simply deinstall 1.8.0.
However so far this has worked for me.
I actually looked at this a little in the disassembler, since source isn't available.
/usr/bin/java and /usr/libexec/java_home both make use of JavaLaunching.framework. The JAVA_HOME environment variable is indeed checked first by /usr/bin/java and friends (but not /usr/libexec/java_home.) The framework uses the JAVA_VERSION and JAVA_ARCH envirionment variables to filter the available JVMs. So, by default:
$ /usr/libexec/java_home -V
Matching Java Virtual Machines (2):
11.0.5, x86_64: "Amazon Corretto 11" /Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
1.8.0_232, x86_64: "Amazon Corretto 8" /Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/amazon-corretto-11.jdk/Contents/Home
But setting, say, JAVA_VERSION can override the default:
$ JAVA_VERSION=1.8 /usr/libexec/java_home
/Library/Java/JavaVirtualMachines/amazon-corretto-8.jdk/Contents/Home
You can also set JAVA_LAUNCHER_VERBOSE=1 to see some additional debug logging as far as search paths, found JVMs, etc., with both /usr/bin/java and /usr/libexec/java_home.
In the past, JavaLaunching.framework actually used the preferences system (under the com.apple.java.JavaPreferences domain) to set the preferred JVM order, allowing the default JVM to be set with PlistBuddy - but as best as I can tell, that code has been removed in recent versions of macOS. Environment variables seem to be the only way (aside from editing the Info.plist in the JDK bundles themselves.)
Setting default environment variables can of course be done through your .profile or via launchd, if you need them be set at a session level.
It's actually pretty easy.
Let's say we have this in our JavaVirtualMachines folder:
jdk1.7.0_51.jdk
jdk1.8.0.jdk
Imagine that 1.8 is our default, then we just add a new folder (for example 'old') and move the default jdk folder to that new folder.
Do java -version again et voila, 1.7!
I tested "jenv" and other things like setting "JAVA_HOME" without success.
Now I ended up with following solution:
function setJava {
export JAVA_HOME="$(/usr/libexec/java_home -v $1)"
launchctl setenv JAVA_HOME $JAVA_HOME
sudo ln -nsf "$(dirname ${JAVA_HOME})/MacOS" /Library/Java/MacOS
java -version
}
(added to ~/.bashrc or ~/.bash.profile or ~/.zshrc)
And calling like that:
setJava 1.8
java_home will handle the wrong input. So you can't do something wrong.
Maven and other stuff will pick up the right version now.
It's pretty simple, if you don't mind rolling up your sleeves... /Library/Java/Home is the default for JAVA_HOME, and it's just a link that points to one of:
/System/Library/Java/JavaVirtualMachines/1.?.?.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/jdk1.?.?_??.jdk/Contents/Home
So I wanted to change my default JVM/JDK version without changing the contents of JAVA_HOME... /Library/Java/Home is the standard location for the current JVM/JDK and that's what I wanted to preserve... it seems to me to be the easiest way to change things with the least side effects.
It's actually really simple. In order to change which version of java you see with java -version, all you have to do is some version of this:
cd /Library/Java
sudo rm Home
sudo ln -s /Library/Java/JavaVirtualMachines/jdk1.8.0_60.jdk/Contents/Home ./Home
I haven't taken the time but a very simple shell script that makes use of /usr/libexec/java_home and ln to repoint the above symlink should be stupid easy to create...
Once you've changed where /Library/Java/Home is pointed... you get the correct result:
cerebro:~ magneto$ java -version
java version "1.8.0_60"
Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM)
64-Bit Server VM (build 25.60-b23, mixed mode)
Oracle's uninstallation instructions for Java 7 worked for me.
Excerpt:
Uninstalling the JDK
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/jdk<major>.<minor>.<macro[_update]>.jdk
For example, to uninstall 7u6:
% rm -rf jdk1.7.0_06.jdk
A bit late but as this is an ongoing issue with Mac OSX...
The simplest solution I found was to simply remove the OpenJDK stuff that Apple installs. Every time an update of Mac OSX arrives it gets installed and you'll need to remove it again.
This works really well if you develop apps for Google App Engine on your mac using Java. The OpenJDK does not work well and the Java version that comes with the Mac OSX Yosemite upgrade will make the Eclipse Plug-in for App Engine crash on every deployment with the helpful error: "Read timed out".
Edit: this information is for visualvm specifically, not for any other java app
As mentioned by others, you need to modify the visualvm.conf
For the latest version of JvisualVM 1.3.6 on Mac, the install directories have changed.
It is currently in
/Applications/VisualVM.app/Contents/Resources/visualvm/etc/visualvm.conf.
However this may depend on where you have installed VisualVM. The easiest way to find where your VisualVM is to start it, and then look at the process using:
ps -ef | grep VisualVM
You will see something like:
... -Dnetbeans.dirs=/Applications/VisualVM.app/Contents/Resources/visualvm/visualvm...
You want to take the netbeans.dir property and look up a directory and you will find the etc folder.
Uncomment this line in the visualvm.conf and change the path to the jdk
visualvm_jdkhome="/path/to/jdk"
Additionally, if you are having slowness with your visualvm and you have a lot of memory, I would suggest greatly increasing the amount of memory available and running it in server mode:
visualvm_default_options="-J-XX:MaxPermSize=96m -J-Xmx2048m -J-Xms2048m -J-server -J-XX:+UseCompressedOops -J-XX:+UseConcMarkSweepGC -J-XX:+UseParNewGC -J-XX:NewRatio=2 -J-Dnetbeans.accept_license_class=com.sun.tools.visualvm.modules.startup.AcceptLicense -J-Dsun.jvmstat.perdata.syncWaitMs=10000 -J-Dsun.java2d.noddraw=true -J-Dsun.java2d.d3d=false"
Simplify the need :-)
Steps to changes --
Find the installed version on your machine by executing following command
/usr/libexec/java_home -V
then you might see like below if there are multiple version of JDK installed
11.0.16 (arm64) "Homebrew" - "OpenJDK 11.0.16" /opt/homebrew/Cellar/blabla
1.8.0_292 (x86_64) "AdoptOpenJDK" - "AdoptOpenJDK 8" /Library/Java/JavaVirtualMachines/bala
Create Env file based your machine, for mac like below create or edit the your system Environment file either .zshenv, .zshprofile etc...
nano ~/.zshenv
export JAVA_HOME=$(/usr/libexec/java_home -v 1.8.0_292)
Then the magic is done, where ever this symlink used all those java refer to version which you set! Happy coding Boys & Girls.
I had a similar situation, and the following process worked for me:
In the terminal, type
vi ~/.profile
Then add this line in the file, and save
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk<version>.jdk/Contents/Home
where version is the one on your computer, such as 1.7.0_25
Exit the editor, then type the following command make it become effective
source ~/.profile
Then type java -version to check the result
java -version
What is .profile?
From:http://computers.tutsplus.com/tutorials/speed-up-your-terminal-workflow-with-command-aliases-and-profile--mac-30515
.profile file is a hidden file. It is an optional file which tells the system which commands to run when the user whose profile file it is logs in. For example, if my username is bruno and there is a .profile file in /Users/bruno/, all of its contents will be executed during the log-in procedure.
MacOS uses /usr/libexec/java_home to find the current Java Version. One way to bypass is to change the plist file as explained by #void256 above.
Other ways is to take the backup of the java_home and replace it with your own script java_home having the code
echo $JAVA_HOME
Now export the JAVA_HOME to the desired version of the SDK by adding the following commands to the ~/.bash_profile.
export JAVA_HOME="/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home"
launchctl setenv JAVA_HOME $JAVA_HOME /// Make the environment variable global
Run the command source ~/.bash_profile to the run the above commands.
Anytime one needs to change the JAVA_HOME he can reset the JAVA_HOME value in the ~/.bash_profile file.
I wanted to change default java version form 1.6* to 1.7*. I tried the following steps and it worked for me:
Removed link "java" from under /usr/bin
Created it again, pointing to the new location:
ln -s /Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/bin/java java
verified with "java -version"
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode)
Hi everybody.
The problem: elcipse-3.5.0 (Galileo) spits with an error when I try to launch it by clicking its launcher. The curse sound like this:
A Java Runtime Environment (JRE) or
Java Development Kit (JDK) must be
available in order to run Eclipse. No
Java virtual machine was found after
searching the following locations:
/home/emanemos/bin/eclipses/eclipse-3.5.0/jre/bin/java
java in your current PATH
However, everything goes smoothly when eclipse is started from console.
Before installing eclipse I've installed jdk1.6.0_16. I also created the $JAVA_HOME variable and changed my $PATH:
$ echo $JAVA_HOME
/usr/lib/java/jdk1.6.0_16
$ echo $PATH
/home/emanemos/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/java/jdk1.6.0_16/jre/bin
So that, my terminal got to know what java is:
$ java -version java version
"1.6.0_16" Java(TM) SE Runtime
Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Client VM (build
14.2-b01, mixed mode, sharing)
Then a folder eclipse was extracted from .tar.gz package under the directory ~/bin/eclipses. I changed the folder's name eclipse to eclipse-3.5.0 and changed $PATH again:
$ echo $PATH
/home/emanemos/bin/eclipses/eclipse-3.5.0:/home/emanemos/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/lib/java/jdk1.6.0_16/jre/bin
From this moment I was blessed to launch eclipse from console by the command eclipse.
However, I feel desperate about using the eclipse's application launcher.
Thanks in advance. I would be grateful for any help.
The message says "No Java virtual machine was found after searching the following locations: /Applications/eclipse/Eclipse.app/Contents/MacOS/jre/bin/"
I have solved it creating the folder /Applications/eclipse/Eclipse.app/Contents/MacOS/jre/bin and linking to the command at /usr/bin/java:
ln -s /usr/bin/java /Applications/eclipse/Eclipse.app/Contents/MacOS/jre/bin/java
Add this to eclipse.ini:-
-vm
$Java_home/jdk1.5.0_14/bin/javaw.exe
I could be off, but it looks to me that you don't have JAVA in your path. If you notice, you had to add it via the echo command. However, that only stays for that session of the terminal. You don't permanently affect the system. (I believe that's why you can launch from the terminal, but not via the launcher.)
Do you have the Java JRE actually installed on your system? If not, I would recommend doing that as that should do all the setup that you would need, then try running Eclipse again.
Edit: I noticed you said that you did install the 1.6 JDK. This should have fixed your problem. If Java is not in your path when you first open up your terminal, then that (I believe) is your real problem and you may need to do a reinstall or troubleshoot there.
(Making a big assumption that you're on Linux using X)
If you've installed the Java JRE without logging out and back in to the X session, the environment the session is in won't contain the $JAVA_HOME variable. It may just be a case of logging out and back in in order to get a new X session.
If you want to keep the same session running, you could try it out by pressing Ctrl+Alt+F9 to start another GUI session.
Fazil Baghirzade i solve the this problem
A Java Runtime Environment (JRE) or Java Development Kit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following locations:
c:\Program Files\Eclipse\jre\bin\javaw.exe 'javaw.exe' in your current path
go to the "C:\Program Files\Java\jdk1.6.0_39" in this folder have "jre" folder copy it and paste the eclipse folder
thats all!!!
I'm trying to run SQuirreL SQL.
I've downloaded it and installed it, but when I try to run it I get this error message:
Java Virtual Machine Launcher.
Could not find the main class.
Program will exit.
I get the gist of this, but I have not idea how to fix it. Any help?
more info:
I'm on Windows XP pro.
I have java 1.6 installed, and other apps are running OK.
The install ran OK.
I believe I've followed the installation instructions correctly.
To run it, I'm invoking the squirrel-sql.bat file.
Update
This question: "Could not find the main class: XX. Program will exit." gives some background on this error from the point of view of a java developer.
Is Java installed on your computer? Is the path to its bin directory set properly (in other words if you type 'java' from the command line do you get back a list of instructions or do you get something like "java is not recognized as a .....")?
You could try try running squirrel-sql.jar from the command line (from the squirrel sql directory), using:
java -jar squirrel-sql.jar
The classpath is the path that the system will follow when trying to find the classes that you're trying to run. In the batch file you're trying to execute it probably has a variable like CLASSPATH=blah;blah;etc or a java command that looks similar to
java -classpath "c:\directory\lib\squirrel-sql.jar" com.some.squirrel.package.file
If you can find or add that classpath setting, make sure that it includes a path to the squirrel-sql.jar and any other jar files that it may depend on separated by semicolons (or the root /lib directory that may be included with the installation).
Basically you just need to tell java where to find the class files that you're trying to execute. Wikipedia has a more indepth discussion about classpath and can offer you more insight. http://en.wikipedia.org/wiki/Classpath_(Java)
JAVA_HOME variable must be set, to point to the prog files/java/version???/bin
open squirrel-sql.bat file with some text editor and see if the JAVA_HOME variable there is the same as the one in your enviroment variable
change it if it doesn't match....and than run bat file again
Have you followed these instructions:
http://www.squirrelsql.org/#installation
If so, are you running the batch file or the shell script to run it?
Tweaking MB's answer for windows, will get rid of the console window:
start javaw -jar squirrel-sql.jar
The .bat file does not seem to work.
Just double-click on:
squirrel-sql.jar
or type:
java -jar squirrel-sql.jar
in the command-line.
You can place .; in classpath in environmental variables to overcome this problem.
I tried to start SQUirrel 3.1 but I received a message stating "Could not find the main class Files\Rational\ClearQuest\cqjni.jar" I noticed that C:\Program Files\Rational\ClearQuest\cqjni.jar is in my existing classpath as defined by the Windows environment variable, CLASSPATH.
SQUirrel doesn't need my existing classpath, so I updated the SQUirrel bat file, squirrel-sql.bat.
REM SET SQUIRREL_CP=%TMP_CP%;%CLASSPATH%
SET SQUIRREL_CP=%TMP_CP%
It no longer appends my existing classpath to its classpath and runs fine.
I had this problem when I "upgraded" to Windows 7, which is 64-bit. My go to Java JRE is a 64-bit JVM. I had a 32-bit JRE on my machine for my browser, so I set up a system variable:
JRE32=C:\Program Files\Java\jre7
When I run:
"%JRE32\bin\java" -version
I get:
java version "1.7.0_51"
Java(TM) SE Runtime Environment (build 1.7.0_51-b13)
Java HotSpot(TM) Client VM (build 24.51-b03, mixed mode, sharing)
Which is a 32-bit JVM. It would say "Java HotSpot(TM) 64-Bit" otherwise.
I edited the "squirrel-sql.bat" file, REMarking out line 4 and adding line 5 as follows:
(4) rem set "IZPACK_JAVA=%JAVA_HOME%"
(5) set IZPACK_JAVA=%JRE32%
And now everything works, fine and dandy.
I had the same issue with a different application (BI Publisher) because I installed a 32 bit version of this application on a 64 bit version of Windows.
Java Virtual Machine Launcher - could not find the main class
The solution for my case was to tell BI Publisher where to find the x86 version of JRE: