m2eclipse无法找到c:program

时间:2023-01-18 23:25:48

I have a problem, concerning the jdk/jre usage of my eclipse. I know that this question was asked and answered a lot of times here and I researched what could be wrong for quite a while. I actually didn't find anything so I'm going to ask you again. Maybe I'm missing something (if yes, I hope it's not to embarrasing :)

关于我的eclipse的jdk/jre使用情况,我有一个问题。我知道这个问题在这里被问了很多次,我研究了一段时间可能是错误的。实际上我什么也没找到所以我要再问你一次。也许我错过了一些东西(如果是的话,我希望它不会让你尴尬)

My problem is, that when I'm running mvn clean install I get an error which says that the m2eclipse plugin is "Unable to locate the Javac Compiler in: C:\Program Files\Java\jre6..\lib\tools.jar".

我的问题是,当我运行mvn全新安装我得到一个错误,说m2eclipse插件是“无法找到的Javac编译器:C:\Program Files\Java\jre6..\lib\ tools.jar”。

First thing I checked was if the right JRE was configured in eclipse. So I switched into Window > Preferences > Java > Installed JREs and checked if the selected jre is the jre inside my jdk folder. This was the case.

我首先检查的是是否在eclipse中配置了正确的JRE。因此,我切换到窗口>首选项> Java >安装了JREs,并检查选中的jre是否是我的jdk文件夹中的jre。就是如此。

I checked the eclipse.ini and added a -vw flag to it. It now looks like:

我检查了eclipse。ini添加了一个-vw标志。现在看起来像:

-startup
plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110502
-product
org.eclipse.epp.package.java.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
 org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
"%JAVA_HOME%\bin\javaw.exe"
-vmargs
-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx384m

The %JAVA_HOME% is resolved to C:\Program Files\Java\jdk1.6.0_24. Since it contains a space I surrounded the vw path with quotes. To check if the path is really correct I tried

将%JAVA_HOME%解析为c:java\ jdk1.6.0_24。因为它包含一个空间,我用引号包围了大众路径。检查路径是否正确,我尝试了。

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24

which tells me that it is correct. I also tried to pass the -vw option when eclipse is started. So the command to start eclipse was then

这告诉我它是正确的。当eclipse启动时,我还试图通过-vw选项。因此,开始eclipse的命令是这样的。

D:\Programs\eclipse\eclipse.exe -vm "%JAVA_HOME%\bin\javaw.exe"

I also tested if there is a difference when I use the %JAVA_HOME% notation or if I writed the full path (it makes no difference).

我还测试了在使用%JAVA_HOME%符号时是否存在差异,或者如果我写了完整的路径(它没有区别)。

The configuration of eclipse, which I get when I go to Help > About Eclipse > Installation Details > Configuration, looks like that:

eclipse的配置,当我帮助>关于eclipse >安装细节>配置时,看起来是这样的:

__wbp.gwt.useWebKit=true
awt.toolkit=sun.awt.windows.WToolkit
veclipse.application=org.eclipse.ui.ide.workbench
eclipse.buildId=M20120208-0800
eclipse.commands=-os
win32
-ws
win32
-arch
x86_64
-showsplash
-launcher
D:\Programs\eclipse\eclipse.exe
-name
Eclipse
--launcher.library
D:\Programs\eclipse\\plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.100.v20110    502\eclipse_1406.dll
-startup
D:\Programs\eclipse\\plugins/org.eclipse.equinox.launcher_1.2.0.v20110502.jar
--launcher.overrideVmargs
-exitdata
3e30_64
-product
org.eclipse.epp.package.java.product
-vm
C:\Program Files\Java\jdk1.6.0_24\bin\javaw.exe
eclipse.home.location=file:/D:/Programs/eclipse/
eclipse.launcher=D:\Programs\eclipse\eclipse.exe
eclipse.launcher.name=Eclipse
eclipse.p2.data.area=@config.dir/../p2/
eclipse.p2.profile=epp.package.java
eclipse.product=org.eclipse.epp.package.java.product
eclipse.startTime=1335643108722
eclipse.vm=C:\Program Files\Java\jdk1.6.0_24\bin\javaw.exe
eclipse.vmargs=-Dosgi.requiredJavaVersion=1.5
-Xms40m
-Xmx384m
-XX:MaxPermSize=256m
[...]

I also tried to use the javaw.exe that is located in %JAVA_HOME%\jre\bin\ which also doesn't change anything.

我也尝试使用javaw。exe位于%JAVA_HOME%\jre\bin\,它也不会改变任何东西。

One thing that is a little bit strange is, that if I delete the reference to the jre, the one that is not included in jdk, in Window > Preferences > Java > Installed JREs I get an error which says "The specified JRE installation does not exist".

有一点很奇怪,如果我删除了对jre的引用,在jdk中没有包含的那个,在Window >偏好中> Java >安装了JREs,我得到了一个错误,它说“指定的jre安装不存在”。

Does anyone have an idea what I'm doing wrong? I think I tried anything to make it work and according to the other articles I found I'm doing it right.

有人知道我做错了什么吗?我想我尝试了任何方法让它工作,根据其他文章我发现我做的是对的。

Btw: I did some Maven "Update Project Dependencies" and "Update Dependencies" which work, so I did not get any error there. The only thing, I did not do is to restart my computer...

顺便说一下,我做了一些Maven“更新项目依赖项”和“更新依赖项”的工作,所以我没有发现任何错误。我唯一没有做的就是重新启动电脑…

7 个解决方案

#1


7  

  1. Go to Windows --> Installed JREs
  2. 到Windows——>安装了JREs。
  3. select the installed JRE and click edit
  4. 选择安装的JRE并单击edit。
  5. change the JRE home directory to PATH_TO_YOURJDK\jre (previously it would be PATH_TO_YOUJRE)
  6. 将JRE主目录更改为PATH_TO_YOURJDK\ JRE(先前它将是PATH_TO_YOUJRE)
  7. this works for me
  8. 这适合我

#2


4  

I figured out a workaround that seems to work. It's not really that what I hoped to be a solution but at least I can use maven now.

我想出了一个似乎可行的办法。这并不是我希望的解决方案,但至少我现在可以使用maven了。

I created a new folder on the same level in the file system as the jdk and the jre folders are. I called it lib and copied the tools.jar file form the jdk into it.

我在文件系统中创建了一个与jdk和jre文件夹相同级别的新文件夹。我把它命名为lib并复制了工具。jar文件将jdk放入其中。

Additionally I switched from the "normal" eclipse for java SE to the eclipse for Java EE (I'm using EJBs). The version of eclipse is the one we got from university so i don't know if a plugin is installed which I missed to install on my (java SE) eclipse.

此外,我从java SE的“正常”eclipse切换到java EE的eclipse(我使用ejb)。eclipse的版本是我们从大学获得的,所以我不知道是否安装了一个插件,我没有安装在我的(java SE) eclipse上。

Now It seems to work but if anybody has a solution that might solve that problem in a more elegant way please let me know.

现在它似乎起作用了,但如果有人有一个解决方案,用更优雅的方式解决这个问题,请告诉我。

#3


3  

See this answer. It suggests that you need to set your PATH to point to the Java bin directory. In my own case this is set:

看到这个答案。这表明您需要设置指向Java bin目录的路径。在我自己的例子中,这是集合:

D:\workspace>echo %PATH%
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem; ...
C:\Program Files\Java\jdk1.7.0_02\bin; ...

#4


2  

EDIT: You mentioned you have the JRE in your JDK referenced in your build path. Well did you notice that tools.jar is NOT in this JRE folder either? tools.jar is contained in the /lib folder only. Not the JRE inside the JDK.

编辑:您提到在您的构建路径中引用了JDK中的JRE。你注意到工具了吗?jar也不在这个JRE文件夹里?工具。jar只包含在/lib文件夹中。不是JDK内部的JRE。

This kept popping up for me in my project as well. For whatever reason, Eclipse keeps telling me it's unable to locate tools.jar. I have fixed it a few time for this project and tonight it came back. Below is how I ended up fixing it once and for all.

这在我的项目中也不断出现。不管出于什么原因,Eclipse一直告诉我它无法定位工具。jar。我已经为这个项目安排了一些时间,今晚它又回来了。下面是我如何最终修复它的方法。

The reason is that you have JRE6 in your included libraries in your Java Build Path. However tools.jar is not included in any JRE, you need to import tools.jar from your JDK.

原因是您在Java构建路径中包含了包含在您的库中的JRE6。然而工具。jar不包含在任何JRE中,您需要导入工具。从您的JDK jar。

By simply going to Properties for -> Java Build path -> Libraries (Tab) -> Add External JARs.. and choosing your JDKs tools.jar file in the /lib folder, it fixes the problem. See the image below.

通过简单地访问-> Java构建路径->库(Tab) ->添加外部jar。选择你的JDKs工具。jar文件在/lib文件夹中,它解决了这个问题。见下面的图片。

m2eclipse无法找到c:program

#5


2  

I notice this is already an old question, but there is a better solution for this. First of all, Eclipse ask "Installed JREs", but actually you should provide the JDK here. Like Styler kind of mentioned, but instead of importing the tools.jar separatedly just define the JDK in "Installed JREs". Then it will find everything there is needed from "basic java" without extra imports to build path (also you should not move anything to or from the JDK folder, this can break the portability of the software). Also notice that when selecting "project" > "Java Compiler" there is an option: "Enable project specific settings". If you have this option selected, it may have a different "JRE" specified to be used than what you have in "Window" > "Preferences" > "Java" > "Installed JREs" selected as default.

我注意到这已经是一个老问题了,但是有一个更好的解决方案。首先,Eclipse要求“安装了JREs”,但实际上您应该在这里提供JDK。就像Styler提到的,但不是导入工具。jar分离只是在“安装的JREs”中定义JDK。然后,它将从“基本java”中找到所需的一切,而不需要额外的导入来构建路径(也不应该将任何东西移到或从JDK文件夹中移动,这会破坏软件的可移植性)。还请注意,在选择“project”>“Java编译器”时,有一个选项:“启用项目特定设置”。如果您选择了这个选项,它可能会有一个不同的“JRE”,指定要比您在“窗口”>“首选项”>“Java”>“安装的JREs”中选择的默认值。

#6


0  

The problem is in definition of your JAVA_HOME

问题在于对JAVA_HOME的定义。

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24

When it should be

当它应该

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24\jre

The variable JAVA_HOME should point to Java Runtime directory.

变量JAVA_HOME应该指向Java运行时目录。

#7


0  

Below are the list of steps that had helped me to solve the issue.

下面是帮助我解决这个问题的步骤列表。

STEP 1:"Properties"(window):

步骤1:“属性”(窗口):

Right-Click on your project->Properties->Java Build Path->JRE System Library(select)-> Edit.

右击你的项目->属性->Java构建路径->JRE系统库(选择)->编辑。

STEP 2:"JRE System Library"(Window):

步骤2:“JRE系统库”(窗口):

Alternate JRE(Select and choose the JRE)-> Installed JREs(Click).

替代JRE(选择并选择JRE)->安装了JREs(单击)。

STEP 3: "Preferences(Filtered)"(Window)

步骤3:“偏好(过滤)”(窗口)

Select the JRE under 'Installed JRE's' -> Edit(Click)

在“安装JRE的”->编辑(单击)下选择JRE

STEP 4: "Edit JRE"(Window)

步骤4:“Edit JRE”(窗口)

Click on 'Add External JARs'

点击“添加外部jar”

STEP 5: "JAR Selection"(Window)

第五步:“JAR Selection”(窗口)

Select the 'tools.jar' (under JDK->lib) --> 'Open' ->'Finish'-->'OK'-->'Finish' --> 'OK'.

选择的工具。jar(在JDK - >*)- - >“打开”- >“完成”- - >“OK”- - >“完成”- - >“OK”。

We are good to go!!! Hope this helps..

我们很好!!!希望这可以帮助. .

#1


7  

  1. Go to Windows --> Installed JREs
  2. 到Windows——>安装了JREs。
  3. select the installed JRE and click edit
  4. 选择安装的JRE并单击edit。
  5. change the JRE home directory to PATH_TO_YOURJDK\jre (previously it would be PATH_TO_YOUJRE)
  6. 将JRE主目录更改为PATH_TO_YOURJDK\ JRE(先前它将是PATH_TO_YOUJRE)
  7. this works for me
  8. 这适合我

#2


4  

I figured out a workaround that seems to work. It's not really that what I hoped to be a solution but at least I can use maven now.

我想出了一个似乎可行的办法。这并不是我希望的解决方案,但至少我现在可以使用maven了。

I created a new folder on the same level in the file system as the jdk and the jre folders are. I called it lib and copied the tools.jar file form the jdk into it.

我在文件系统中创建了一个与jdk和jre文件夹相同级别的新文件夹。我把它命名为lib并复制了工具。jar文件将jdk放入其中。

Additionally I switched from the "normal" eclipse for java SE to the eclipse for Java EE (I'm using EJBs). The version of eclipse is the one we got from university so i don't know if a plugin is installed which I missed to install on my (java SE) eclipse.

此外,我从java SE的“正常”eclipse切换到java EE的eclipse(我使用ejb)。eclipse的版本是我们从大学获得的,所以我不知道是否安装了一个插件,我没有安装在我的(java SE) eclipse上。

Now It seems to work but if anybody has a solution that might solve that problem in a more elegant way please let me know.

现在它似乎起作用了,但如果有人有一个解决方案,用更优雅的方式解决这个问题,请告诉我。

#3


3  

See this answer. It suggests that you need to set your PATH to point to the Java bin directory. In my own case this is set:

看到这个答案。这表明您需要设置指向Java bin目录的路径。在我自己的例子中,这是集合:

D:\workspace>echo %PATH%
C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;
C:\Windows;C:\Windows\System32\Wbem; ...
C:\Program Files\Java\jdk1.7.0_02\bin; ...

#4


2  

EDIT: You mentioned you have the JRE in your JDK referenced in your build path. Well did you notice that tools.jar is NOT in this JRE folder either? tools.jar is contained in the /lib folder only. Not the JRE inside the JDK.

编辑:您提到在您的构建路径中引用了JDK中的JRE。你注意到工具了吗?jar也不在这个JRE文件夹里?工具。jar只包含在/lib文件夹中。不是JDK内部的JRE。

This kept popping up for me in my project as well. For whatever reason, Eclipse keeps telling me it's unable to locate tools.jar. I have fixed it a few time for this project and tonight it came back. Below is how I ended up fixing it once and for all.

这在我的项目中也不断出现。不管出于什么原因,Eclipse一直告诉我它无法定位工具。jar。我已经为这个项目安排了一些时间,今晚它又回来了。下面是我如何最终修复它的方法。

The reason is that you have JRE6 in your included libraries in your Java Build Path. However tools.jar is not included in any JRE, you need to import tools.jar from your JDK.

原因是您在Java构建路径中包含了包含在您的库中的JRE6。然而工具。jar不包含在任何JRE中,您需要导入工具。从您的JDK jar。

By simply going to Properties for -> Java Build path -> Libraries (Tab) -> Add External JARs.. and choosing your JDKs tools.jar file in the /lib folder, it fixes the problem. See the image below.

通过简单地访问-> Java构建路径->库(Tab) ->添加外部jar。选择你的JDKs工具。jar文件在/lib文件夹中,它解决了这个问题。见下面的图片。

m2eclipse无法找到c:program

#5


2  

I notice this is already an old question, but there is a better solution for this. First of all, Eclipse ask "Installed JREs", but actually you should provide the JDK here. Like Styler kind of mentioned, but instead of importing the tools.jar separatedly just define the JDK in "Installed JREs". Then it will find everything there is needed from "basic java" without extra imports to build path (also you should not move anything to or from the JDK folder, this can break the portability of the software). Also notice that when selecting "project" > "Java Compiler" there is an option: "Enable project specific settings". If you have this option selected, it may have a different "JRE" specified to be used than what you have in "Window" > "Preferences" > "Java" > "Installed JREs" selected as default.

我注意到这已经是一个老问题了,但是有一个更好的解决方案。首先,Eclipse要求“安装了JREs”,但实际上您应该在这里提供JDK。就像Styler提到的,但不是导入工具。jar分离只是在“安装的JREs”中定义JDK。然后,它将从“基本java”中找到所需的一切,而不需要额外的导入来构建路径(也不应该将任何东西移到或从JDK文件夹中移动,这会破坏软件的可移植性)。还请注意,在选择“project”>“Java编译器”时,有一个选项:“启用项目特定设置”。如果您选择了这个选项,它可能会有一个不同的“JRE”,指定要比您在“窗口”>“首选项”>“Java”>“安装的JREs”中选择的默认值。

#6


0  

The problem is in definition of your JAVA_HOME

问题在于对JAVA_HOME的定义。

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24

When it should be

当它应该

C:\Windows\System32>echo %JAVA_HOME%
C:\Program Files\Java\jdk1.6.0_24\jre

The variable JAVA_HOME should point to Java Runtime directory.

变量JAVA_HOME应该指向Java运行时目录。

#7


0  

Below are the list of steps that had helped me to solve the issue.

下面是帮助我解决这个问题的步骤列表。

STEP 1:"Properties"(window):

步骤1:“属性”(窗口):

Right-Click on your project->Properties->Java Build Path->JRE System Library(select)-> Edit.

右击你的项目->属性->Java构建路径->JRE系统库(选择)->编辑。

STEP 2:"JRE System Library"(Window):

步骤2:“JRE系统库”(窗口):

Alternate JRE(Select and choose the JRE)-> Installed JREs(Click).

替代JRE(选择并选择JRE)->安装了JREs(单击)。

STEP 3: "Preferences(Filtered)"(Window)

步骤3:“偏好(过滤)”(窗口)

Select the JRE under 'Installed JRE's' -> Edit(Click)

在“安装JRE的”->编辑(单击)下选择JRE

STEP 4: "Edit JRE"(Window)

步骤4:“Edit JRE”(窗口)

Click on 'Add External JARs'

点击“添加外部jar”

STEP 5: "JAR Selection"(Window)

第五步:“JAR Selection”(窗口)

Select the 'tools.jar' (under JDK->lib) --> 'Open' ->'Finish'-->'OK'-->'Finish' --> 'OK'.

选择的工具。jar(在JDK - >*)- - >“打开”- >“完成”- - >“OK”- - >“完成”- - >“OK”。

We are good to go!!! Hope this helps..

我们很好!!!希望这可以帮助. .