Eclipse 中的 GlassFish 抱怨“GlassFish v3 需要 JDK 1.6 而不是 JRE”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6082936/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
GlassFish in Eclipse complains "GlassFish v3 requires a JDK 1.6 and not a JRE"
提问by Grunge Freak
I am running:
我在跑步:
- Eclipse Java EE IDE for Web Developers.
- Version: Helios Service Release 2
- Build id: 20110218-0911
- 面向 Web 开发人员的 Eclipse Java EE IDE。
- 版本:Helios Service Release 2
- 版本号:20110218-0911
I have also installed Java EE 6 SDK Update 2 which includes:
我还安装了 Java EE 6 SDK Update 2,其中包括:
- GlassFish Open Source Edition 3.1
- Java EE 6 Code Samples
- Java EE 6 API Documentation
- Java EE 6 Tutorial
- Your First Cup: An Introduction to the Java EE Platform
- GlassFish 开源版 3.1
- Java EE 6 代码示例
- Java EE 6 API 文档
- Java EE 6 教程
- 你的第一杯:Java EE 平台简介
I have registered GlassFish with Eclipse but when I try to start the server, I get the following error:
我已经在 Eclipse 中注册了 GlassFish,但是当我尝试启动服务器时,出现以下错误:
GlassFish v3 requires a JDK 1.6 and not a JRE. Please add/select the correct JDK in the Server properties 'Runtime Environment' section.
GlassFish v3 需要 JDK 1.6 而不是 JRE。请在服务器属性“运行时环境”部分添加/选择正确的 JDK。
I have searched here for an answer but none so far seem to work. Can anybody suggest how I would sort this error out?
我在这里搜索了答案,但到目前为止似乎都没有。有人可以建议我如何解决这个错误吗?
采纳答案by duffymo
Yes, you downloaded (or pointed Eclipse to) a JRE, but it needs a JDK. The latter has all the Java tools: javac.exe, java.exe, jar.exe, etc.
是的,您下载(或将 Eclipse 指向)一个 JRE,但它需要一个 JDK。后者拥有所有的 Java 工具:javac.exe、java.exe、jar.exe 等。
If you look at the directory where you told Eclipse to look for a JDK, you must see a /bin directory with those .exe files in it. If you don't, you know why the error message.
如果查看您告诉 Eclipse 查找 JDK 的目录,您必须看到一个 /bin 目录,其中包含那些 .exe 文件。如果不这样做,您就会知道为什么会出现错误消息。
Make sure you downloaded a JDK and point Eclipse to it.
确保您下载了 JDK 并将 Eclipse 指向它。
One more check: see if you can start Glassfish without Eclipse. You're ignorant of two things if you're learning both at the same time. Leave one unknown out of the equation until you can make Glassfish run on its own.
再检查一项:看看您是否可以在没有 Eclipse 的情况下启动 Glassfish。如果你同时学习两件事,你就会对两件事一无所知。在您可以让 Glassfish 自行运行之前,将一个未知数排除在等式之外。
You need a JAVA_HOME environment variable. What's it pointing to? If you don't have one, create it.
您需要一个 JAVA_HOME 环境变量。它指的是什么?如果您没有,请创建它。
回答by png
I had the same issue and actually i got the solution from this link ( The above answers really didnt gave me the solution
我有同样的问题,实际上我从这个链接得到了解决方案(上面的答案确实没有给我解决方案
https://forums.oracle.com/forums/thread.jspa?messageID=7033028
https://forums.oracle.com/forums/thread.jspa?messageID=7033028
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
1)确保安装了jdk。查看 C:\Program Files\Java\jdk1.6.XXXX(我的说是 0_16)。如果里面有东西,可能已经安装了 jdk,如果没有,你可以从http://java.sun.com/javase/downloads/index.jsp获取 jdk
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...
2)这是错误消息有点foobars ya... - 开始eclipse,忽略消息。- 转到 Window>Preferences - 然后在 +Java+Installed JREs 下点击 Add。- 选择“Standard VM”然后下一步 - JRE Home = C:\Program Files\Java\jdk1.6.XXXX 其余的应该自动填写。点击完成。- 最重要的!!!单击新 jdk 运行时的首选项窗口中的复选框......我不知道为什么它是必要的,但它绝对是......
3)Still in 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.
3) 仍在首选项窗口中。- 进入 +Server, Runtime Environments - 选择 Glassfish SRE,点击 Edit... - 从 JRE 下拉菜单中选择 JDK 并点击 Finish - 点击 Okay。
4)Go to the Servers Veiw (probably down by the Console View). Right click on the Bundled Glassfish...Server and hit restart/start...
4)转到服务器视图(可能在控制台视图旁边)。右键单击 Bundled Glassfish...Server 并点击重新启动/启动...
回答by morellet.d
For other people like me who still have a problem, try to be careful in your JRE Definition :
对于像我这样仍然有问题的其他人,请尽量小心您的 JRE 定义:
Don't use this : C:\Program Files\Java\jdk1.6.0_29\jre
不要使用这个: C:\Program Files\Java\jdk1.6.0_29\jre
but this : C:\Program Files\Java\jdk1.6.0_29
但是这个 : C:\Program Files\Java\jdk1.6.0_29
and Glassfish will eventually work.
Glassfish 最终会起作用。
回答by Martin Charlesworth
It took me a while to find where this is configured in eclipse so I'll note it here for everyone:
找了好久才在eclipse中找到这个配置的地方,所以在这里给大家记录一下:
Window menu > Preferences dialog > Server section > Runtime Environments subsection.
窗口菜单 > 首选项对话框 > 服务器部分 > 运行时环境子部分。