vale4674
vale4674

Reputation: 4271

MacOSX Snow Leopard and Eclipse: Error starting Eclipse (No Java virtual machine....)

This is so frustrating.

I did no update of java nor eclipse and suddenly I can't open eclipse. I even didn't install any other programs. Here is the error:

error

I've tried everything. I updated to new java version and no luck on that: java versions

I downloaded the newest eclipse and had no luck.

Then I updated eclipse's Info.plist file:

Added: <string>-vm</string><string>/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java</string>

Info.plist

From terminal:

terminal

What else could I do?

EDIT:

Path variable:

PATH

EDIT 2: Strange behavior. If I go right click on eclipse.app and navigate through: Contents/MacOS/eclipse and double click it then a terminal opens and eclipse starts: eclipseFromTermina

Why is that so. I want to run eclipse directly from eclipse.app, not through Contents/.....

EDIT 3:

I see that someone had the same exact problem as me but I haven' find the solution yet: http://www.eclipse.org/forums/index.php/t/107226/

Upvotes: 6

Views: 5194

Answers (7)

Vaiden
Vaiden

Reputation: 16122

I've fixed this using a 2 step solution:

*1. Set JAVA_HOME correctly:*

Find out the Java JDK location:

/usr/libexec/java_home

Create the ~/.bash_profile if needed:

touch ~/.bash_profile

Edit the .bash_profile file using TextEdit, and add the following lines (change the paths as necessary):

export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_51.jdk/Contents/Home/ export PATH=$JAVA_HOME/bin:$PATH

2. Set the alias to be executable:

From the eclipse install location, run:

chmod +x ./eclipse

Now to activate Eclipse I open Finder, navigate the to eclipse installation directory and double click the alias file (named eclipse, but without the eclipse icon).

Upvotes: 0

C&#233;dric
C&#233;dric

Reputation: 1

I've encountered the same issue but a simple

chmod +x Contents/MacOS/eclipse

in the package content, did the trick.

Upvotes: 0

Christopher Williams
Christopher Williams

Reputation: 2907

Editing the plist file is not the recommended way of setting the JVM. See http://wiki.eclipse.org/FAQ_How_do_I_run_Eclipse%3F#Find_the_JVM and it points you to http://wiki.eclipse.org/Eclipse.ini#Specifying_the_JVM

Basically inside Eclipse.app/MacOS/eclipse.ini is where you'll want to specify command line arguments that get passed to eclipse by default. Granted the plist's array of arguments are also used, but that isn't how the Eclipse docs themselves recommend setting arguments (and it is possible that as a result, it might get wiped when you update Eclipse again).

You'd want to remove the vm entry from that Array in the plist and instead add the following in the eclipse.ini before "-vmargs":

-vm
/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/bin/java

Upvotes: 2

vale4674
vale4674

Reputation: 4271

OK, after a few days of struggling and with no luck on this thread and Eclipse forums THREAD I started a bounty for this question and had no correct answer.

I found a solution to this problem (this stack).

ANSWER:

You need to edit the Eclipse.app/Contents/Info.plist file and add two lines in it:

enter image description here

Nowhere stated that this lines had to go in Eclipse array but just somewhere up as key-string.

If you don't have Xcode, edit that file with textedit:

    <key>Eclipse</key>
<array>
    <string>-vm</string>
    <string>/System/Library/Frameworks/JavaVM.framework/Home/bin/java</string>
    <string>-keyring</string>
    <string>~/.eclipse_keyring</string>
    <string>-showlocation</string>
</array>

Upvotes: 14

Max
Max

Reputation: 2907

You need to create a file ~/.MacOSX/environment.plist and add JAVA_HOME => /Library/Java/Home entry into it. If you have XCode installed, use it to add entry. Otherwise, use plain text editor:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>JAVA_HOME</key>
    <string>/Library/Java/Home</string>
</dict>
</plist>

After that, restart MaxOS or logout/login.

See http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPRuntimeConfig/Articles/EnvironmentVars.html for details.

Cheers, Max

Upvotes: 1

try to add this to your ~/.profile

export JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/
export PATH=$JAVA_HOME/bin:$PATH

Upvotes: 1

Michael Shopsin
Michael Shopsin

Reputation: 2138

Try moving your workspace and deleting the configs (rm -rf ~/.eclipse). Sometimes Eclipse messes up its env and needs to be reset.

Upvotes: 3

Related Questions