Linux Java 不适用于 ubuntu 11.10 上的 netbeans IDE 7
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/10228225/
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
Java is not working with netbeans IDE 7 on ubuntu 11.10
提问by Vipin Kr. Singh
I am using Netbeans IDE 7.1.1 on ubuntu 11.10, when I try to create JAVA project using File-> New Project-> JAVA Project-> JAVA Application, it shows me the following error:
我在 ubuntu 11.10 上使用 Netbeans IDE 7.1.1,当我尝试使用 File-> New Project-> JAVA Project-> JAVA Application 创建 JAVA 项目时,它显示了以下错误:
The JDK is missing an required to run some NetBeans modules. Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJrefor more information.
JDK 缺少运行某些 NetBeans 模块所必需的。请使用 --jdkhome 命令行选项指定 JDK 安装或查看http://wiki.netbeans.org/FaqRunningOnJre了解更多信息。
So I used the following command
所以我使用了以下命令
sudo update-alternatives --config java
and the result was:
结果是:
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
* 2 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1051 manual mode
I tried to run through terminal using the following command:
我尝试使用以下命令通过终端运行:
netbeans --jdkhome /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java
but I got error:
但我有错误:
Cannot find java. Please use the --jdkhome switch.
and netbeans doesn't start as well.
并且 netbeans 也不会启动。
I tried this command using every path which I found through this command also:
我还使用通过此命令找到的每个路径尝试了此命令:
whereis java
but every time I got the same error and netbeans doesn't start.
但是每次我遇到相同的错误并且 netbeans 都无法启动时。
in netbeans config file (/usr/local/netbeans-7.0/etc/netbeans.conf
) jdkhome path is :
在 netbeans 配置文件 ( /usr/local/netbeans-7.0/etc/netbeans.conf
) 中 jdkhome 路径是:
netbeans_jdkhome="/usr/lib/jvm/java-7-openjdk-i386/jre"
when I tried to run netbeans using this path through this command:
当我尝试通过以下命令使用此路径运行 netbeans 时:
netbeans --jdkhome /usr/lib/jvm/java-7-openjdk-i386/jre
netbeans runs but when try to create project the same JDK missing error is displayed.
netbeans 运行但是当尝试创建项目时显示相同的 JDK 丢失错误。
One interesting thing also I encountered, if I use Eclipse every thing goes fine, I am able to create projects in eclipse and programs run smoothly. Eclipse doesn't show any wanning or errors like JDK is missing.
我还遇到了一件有趣的事情,如果我使用 Eclipse 一切顺利,我可以在 Eclipse 中创建项目并且程序运行顺利。Eclipse 没有显示任何 wanning 或错误,例如缺少 JDK。
采纳答案by Max
I use Netbeans 7.1 on Ubuntu 11.10 and it works great, I didn't need to specify anything extra to get the JDK working. Here is my update-alternatives
:
我在 Ubuntu 11.10 上使用 Netbeans 7.1 并且它工作得很好,我不需要指定任何额外的东西来让 JDK 工作。这是我的update-alternatives
:
Selection Path Priority Status
------------------------------------------------------------
0 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 auto mode
* 1 /usr/lib/jvm/java-6-openjdk/jre/bin/java 1061 manual mode
How did you install Netbeans 7.1? As far as I remember it is not in the repositories. I used the GUI Swing installer from the Netbeans website. I installed it as a usernot using sudo
or su
.
你是如何安装 Netbeans 7.1 的?据我所知,它不在存储库中。我使用了 Netbeans 网站上的 GUI Swing 安装程序。我以不使用或的用户身份安装它。sudo
su
Also check how you runNetbeans, try going to NETBEANS/bin
folder and running ./netbeans
.
还要检查您如何运行Netbeans,尝试转到NETBEANS/bin
文件夹并运行./netbeans
.
回答by Mayur Patil
Hi Vinay, I have come across the solution which will work on any version of Ubuntu definitely keeping other java versions intact.
嗨 Vinay,我遇到了可以在任何版本的 Ubuntu 上运行的解决方案,绝对可以保持其他 Java 版本的完整性。
For this, please download tar.gz version of Java from Oracle website.
为此,请从Oracle 网站下载 tar.gz 版本的 Java 。
Suppose, your jdk installation tar file at location
/home/don/
don@ubuntu ~ $
tar zxf jdk-7u45-linux-i586.tar.gz
don@ubuntu ~ $
sudo bash
[sudo] password for don:
ubuntu ~ #
mv /home/don/jdk1.7.0_45/ /usr/lib/jvm/
ubuntu ~ #
cd /usr/lib/jvm/
ubuntu jvm #
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_45/bin/java 3
ubuntu jvm #
update-alternatives --config java
假设,您的 jdk 安装 tar 文件位于
/home/don/
唐@ubuntu ~ $
tar zxf jdk-7u45-linux-i586.tar.gz
唐@ubuntu ~ $
sudo bash
[sudo] 唐的密码:
ubuntu~#
mv /home/don/jdk1.7.0_45/ /usr/lib/jvm/
ubuntu~#
cd /usr/lib/jvm/
ubuntu jvm #
update-alternatives --install /usr/bin/java java /usr/lib/jvm/jdk1.7.0_45/bin/java 3
ubuntu jvm #
update-alternatives --config java
Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071 auto mode 1 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071 manual mode 2 /usr/lib/jvm/jdk1.7.0_45/bin/java 3 manual mode Press enter to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in manual mode
Selection Path Priority Status ------------------------------------------------------------ * 0 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071 auto mode 1 /usr/lib/jvm/java-7-openjdk-i386/jre/bin/java 1071 manual mode 2 /usr/lib/jvm/jdk1.7.0_45/bin/java 3 manual mode Press enter to keep the current choice[*], or type selection number: 2 update-alternatives: using /usr/lib/jvm/jdk1.7.0_45/bin/java to provide /usr/bin/java (java) in manual mode
- ubuntu jvm #
java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM (build 24.45-b08, mixed mode)
- ubuntu jvm #
java -version
java version "1.7.0_45"
Java(TM) SE Runtime Environment (build 1.7.0_45-b18)
Java HotSpot(TM) Server VM(build 24.45-b08,混合模式)
Done !!
完毕 !!
Now, the turn of netbeans.
现在,轮到网豆了。
I assumed your file is saved at location /home/don.
我假设您的文件保存在位置 /home/don。
On netbeans installation file, right click -> properties
-> permissions
-> Allow executing file as a program
under Execute attribute.
在 netbeans 安装文件上,右键单击 -> properties
-> permissions
->Allow executing file as a program
在 Execute 属性下。
Now click on installer, select run when asks for action and your installation will start without any hassles.
现在单击安装程序,在要求操作时选择运行,您的安装将开始,没有任何麻烦。
Happy programming !!
编程快乐!!