7

I am trying to get glassfish working in eclipse, and running into the JRE vs JDK error:

GlassFish v3 requires a JDK 1.6 and not a JRE. Please add/select the correct JDK in the Server properties 'Runtime Environment' section.

I googled around and it seems a bunch of people had this issue. Sure enough in preferences->Server-> Runtime Environment when I clicked edit on the glassfish server runtime environment the JRE was "default JRE". I clicked the dropdown menu and switched it to my JDK: java-6-openjdk and figured I had the problem solved. Unfortunately, I am still getting the exact same error. This leaves me at a loss on how to google the issue since everyone else seems to have resolved it by just switching the JRE to a JDK. Does anyone have any thoughts?

Avtar

Basic
  • 26,321
  • 24
  • 115
  • 201
akhalsa
  • 2,303
  • 3
  • 25
  • 43
  • Though this apparently did not work for you, future visitors see [GlassFish in Eclipse complains “GlassFish v3 requires a JDK 1.6 and not a JRE”](http://stackoverflow.com/questions/6082936/glassfish-in-eclipse-complains-glassfish-v3-requires-a-jdk-1-6-and-not-a-jre/8279434#8279434). – Arjan Jan 13 '12 at 20:49

5 Answers5

24
  1. make sure the jdk is installed. Look in C:\Program Files\Java\jdk1.6.XXXX (mine says 0_16). If that has stuff in it the jdk probably was installed, if not you can grab just the jdk from http://java.sun.com/javase/downloads/index.jsp

  2. This is where the error message kinda foobars ya.

    • Get eclipse started, ignore the message.
    • Go to Window>Preferences
    • Then under +Java+Installed JREs hit Add.
    • Select Standard VM then Next
    • JRE Home = C:\Program Files\Java\jdk1.6.XXXX the rest should fill in automagically. Hit Finish.
    • MOST IMPORTANT! Click the check box back in the Preferences Window for the new jdk runtime...I don't know why it's necessary, but it definitely is...
  3. Still in Preference Window. (May have to hit Okay, and re-open Preference window)

    • Get to +Server, Runtime Environments
    • Select the Glassfish SRE, hit Edit...
    • From the JRE drop down grab the JDK and hit Finish
    • Hit Okay.
  4. Go to the Servers Veiw (probably down by the Console View). Right click on the Bundled Glassfish...Server and hit restart/start...

Hopefuly this fixes it...

AlecPerkey
  • 659
  • 2
  • 11
  • 21
abin babu
  • 241
  • 2
  • 2
  • Even though all my environment variables were set, I first had to do this in order to get it to work. (Just in case someone wonders oneday) –  Jul 30 '13 at 12:27
  • This fixed the problem for me - quick and easy. Voted up. – user359519 Mar 31 '14 at 16:00
3

Try setting Eclipse running in JDK as well — maybe Glassfish picks its JDK. To do this, edit eclipse.ini, and add the line

 -vm 
 path-to-javaw.exe-in-a-JDK

With this configuration, I never had this issue.

MaDa
  • 10,511
  • 9
  • 46
  • 84
  • I have my jdk in the directory: /usr/lib/jvm/java-6-openjdk which contains the bin folder which has the java and the javaws files (although no javaw... perhaps that is the problem?) I tried setting the flag in the eclipse.ini file both as /usr/lib/jvm/java-6-openjdk and /usr/lib/jvm/java-6-openjdk/bin and neither one worked. – akhalsa Oct 03 '11 at 18:10
  • 1
    @user659874 See my edited answer. The "-vm" and the path must be in separate lines, otherwise they don't work. – MaDa Oct 03 '11 at 18:26
  • Thank you for the reply. Do you know if I need the path to include bin or not? – akhalsa Oct 03 '11 at 18:32
  • Thank you for the help. Unfortunately neither directory worked. My eclipse.ini file looks like this: -vm /usr/lib/jvm/java-6-openjdk/ and I am getting the same result – akhalsa Oct 03 '11 at 18:41
  • @user659874 Ooops, sorry for my Windowish example. Eclipsepedia says in Linux you must provide a full path to java executable, so in your example it would probably be /usr/lib/jvm/java-6-openjdk/bin/java. – MaDa Oct 03 '11 at 18:43
  • It seems that I was mistaken before. The error seemed to in fact come from using the version of java that came with my eclipse download. I just did apt-get to download the latest JRE and JDK's pointed glassfish at them, and it worked – akhalsa Oct 06 '11 at 23:11
  • @user659874 Feel free to share your Linux configuration with the -vm option - add another answer perhaps. I'd gladly see it and upvote. – MaDa Oct 07 '11 at 07:00
  • You really should be able to set a specific JDK for GlassFish, when started from Eclipse, though apparently that did not work for the OP. See [GlassFish in Eclipse complains “GlassFish v3 requires a JDK 1.6 and not a JRE”](http://stackoverflow.com/questions/6082936/glassfish-in-eclipse-complains-glassfish-v3-requires-a-jdk-1-6-and-not-a-jre/8279434#8279434). – Arjan Jan 13 '12 at 20:50
2

Go to Window -> Preferences -> Server -> Runtime Environment. Select GlassFish x.x.x click Edit and select the installed JDK in JRE option. If you couldn't see JDK in the options, goto Window -> Preferences -> installed JREs and click Add... and browse to JDK folder you want to add.

Mike
  • 725
  • 2
  • 11
  • 21
1

simple hit ok when you'll start glassfish from eclipse , as it is asking for username and password . after 10 times typing my username and password i was still out. so , simple hit ok without entering your name and pass

mamuka
  • 11
  • 1
0

Get to +Server, Runtime Environments Select the Glassfish SRE, hit Edit... From the JRE drop down grab the JDK and hit Finish Hit Okay.Worked well for me

Xyz
  • 1