Saya telah mengikuti tutorial memulai, tetapi terhenti setelah saya mengimpor proyek playn menggunakan Maven. Saya menggunakan Eclipse Indigo yang berjalan pada 64bit Windows 7.
Semua proyek yang diimpor memiliki kesalahan yang sama:
Missing Artifact com.sun:tools:jar in all the pom.xml files.
Setelah beberapa jam mencari forum, saya telah mencoba:
Menginstal Java 1.6.029 terbaru. Mengubah JAVA_HOME
variabel lingkungan saya agar mengarah ke \program files\Java\jdk1.6_029
Mengubah preferensi Eclipse Java saya untuk menggunakan JRE jdk1.6_029
.
Saya sangat ingin bereksperimen dengan playn, tetapi mengapa ada beberapa posting, saya sepertinya tidak dapat menemukan jawaban konsensus tentang solusinya. Beberapa orang mengatakan Sun menghapus sesuatu dari 64bit jdk, yang lain mengatakan Anda harus mengedit file xml Anda, banyak orang mengatakan Anda telah mengubah Anda JAVA_HOME
, dan yang lain mengatakan Anda harus mengubah opsi VM Anda untuk Eclipse.
Setiap bantuan untuk menyelesaikan ini akan dihargai, dan mungkin berguna bagi banyak orang, karena saya tidak memiliki pengaturan yang aneh di sini.
(edit) Berikut adalah pom.xml di proyek pertama. Eclipse menandai kesalahan di baris yang berbunyi:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-project</artifactId>
<version>1.1-SNAPSHOT</version>
</parent>
<artifactId>playn-android</artifactId>
<name>PlayN Android</name>
<packaging>jar</packaging>
<repositories>
</repositories>
<dependencies>
<dependency>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-core</artifactId>
<version>${project.version}</version>
</dependency>
<!-- needed because Android uses the same JSON code as playn-java;
that should be factored into a library shared by both backends -->
<dependency>
<groupId>com.googlecode.playn</groupId>
<artifactId>playn-java</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.google.android</groupId>
<artifactId>android</artifactId>
<version>${android.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
</build>
</project>
Jawaban:
I just posted over on this question about this same issue and how I resolved it, but I'll paste (and expand on) it here as well, since it seems more relevant.
I had the same issue when using Eclipse in Windows 7, even when I removed the JRE from the list of JREs in the Eclipse settings and just had the JDK there.
What I ended up having to do (as you mentioned in your question) was modify the command-line for the shortcut I use to launch Eclipse to add the -vm argument to it like so:
-vm "T:\Program Files\Java\jdk1.6.0_26\bin"
Of course, you would adjust that to point to the bin directory of your JDK install. What this does is cause Eclipse itself to be running using the JDK instead of JRE, and then it's able to find the
tools.jar
properly.I believe this has to do with how Eclipse finds its default JRE when none is specified. I'm guessing it tends to prefer JRE over JDK (why, I don't know) and goes for the first compatible JRE it finds. And if it's going off of Windows registry keys like Vladiat0r's answer suggests, it looks for the
HKLM\Software\JavaSoft\Java Runtime Environment
key first instead of theHKLM\Software\JavaSoft\Java Development Kit
key.sumber
javaw.exe
to that path as well (so in full:-vm "T:\Program Files\Java\jdk1.8.0_66\bin\javaw.exe"
);I had the same trouble while developing a simple, web service application, in my case I had to add a codehous plug in in order to get jaxws libraries. However, maven pom kept on asking about the tools jar file.
I have to say above comments are correct, you can include the below entry in the pom file:
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.6.0_29\lib\tools.jar</systemPath> </dependency>
But, what will it happen when you have to deploy to a production instance? You could replace the path with a reference to a system environment variable but that still does not look good, at least to me.
I found another solution in a StackOverflow comment:
Maven 3 Artifact problem
<dependency> <groupId>org.apache.struts</groupId> <artifactId>struts2-core</artifactId> <version>${struts2.version}</version> <exclusions> <exclusion> <artifactId>tools</artifactId> <groupId>com.sun</groupId> </exclusion> </exclusions> </dependency>
They suggest including an exclusion statement for tool jar and it works. So summarizing: you can include an exclusion rule within your dependency and avoid having the tool.jar issue:
<exclusions> <exclusion> <artifactId>tools</artifactId> <groupId>com.sun</groupId> </exclusion> </exclusions>
sumber
pom.xml
doesn't work for me.I ran into the same problem and the way I was able to resolve it was add the dependency location of
tools.jar
into thepom.xml
. Like so:<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.6.0_29\lib\tools.jar</systemPath> </dependency>
Make sure you change the
<systemPath>
to where ever your tools.jar file is located.sumber
None of the other answers did it for me. What did it was to check for "Dependency hierarchy" of the pom.xml in eclipse, where giving a filter 'tools' revealed that I had a real dependency to tools.jar:
So the culprit for me was this:
<dependency> <groupId>com.github.markusbernhardt</groupId> <artifactId>robotframework-selenium2library-java</artifactId> <version>1.4.0.7</version> <scope>test</scope> </dependency>
Adding an exclusion fixed it:
<dependency> <groupId>com.github.markusbernhardt</groupId> <artifactId>robotframework-selenium2library-java</artifactId> <version>1.4.0.7</version> <scope>test</scope> <exclusions> <exclusion> <artifactId>tools</artifactId> <groupId>com.sun</groupId> </exclusion> </exclusions> </dependency>
The exclusion doesn't seem to have any downsides to it.
sumber
The same with me and Windows 7. I ended up adding two lines to
eclipse.ini
:-vm C:\Program Files\Java\jdk1.6.0_35\bin
I tried using
%JAVA_HOME%
there, but it did not work.sumber
-vmargs
line, as anything past that will be interpreted as VM startup args. So: right before that one!-vm
before the-vmargs
is the key!. Thank you!I solved this problem in Eclipse 4.3 settings - only by adding JDK libraries to JRE's libraries.
Go windows -> settings -> Java -> installed JREs -> select JDK and click Edit -> click Add External JARs and add tools.jar (placed in JDK/lib)
sumber
Check the JDK version on your machine and in
pom.xml
both should be same<dependency> <groupId>sun.jdk</groupId> <artifactId>tools</artifactId> <version>1.8</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.8.0_192\lib\tools.jar</systemPath> </dependency>
sumber
If this problem still happens, it might be because of a JDK of version equal or greater than 11.
The
tools.jar
archive has been removed from the lib folder in those JDK's (see this answer to a similar question). In that case, try to use other versions of the libraries, that do not rely on thecom.sun:tools
library.sumber
After struggling for a while I finally got this to work with
eclipse.ini
instead of the command line. After finally reading the documentation I realized that the -vm argument must be on a separate line, unquoted, and ahead of any -vmargs:-vm C:\Program Files\Java\jdk1.7.0_45\bin\javaw.exe
sumber
I got similar error. This is because JDK is not properly set in eclipse. Cucumber needs JDK along with JRE, so add below dependency in your pom.xml
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.8.0_101\lib\tools.jar</systemPath> </dependency>
sumber
In the effective POM tab of the pom files, I see the following derive path:
C:\Program Files\Java\jre6/../lib/tools.jar
and I think it's not a valid path in Windows. I tried copying the tools.jar in the jre6/lib folder as well as in Java/lib without success.The value "C:\Program Files\Java\jre6" comes from the registry
HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6.0_30 HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment\1.6
And set the JavaHome key to where your jdk JRE is installed. Then all the compiler errors went away.
Reinstalling the JDK didn't fix it. Setting the JAVA_HOME or java.home system environment variable didn't help.
The other alternative I've seen is adding the dependency with the right path in each pom xml file, but the playn-samples has lots of files that is a ridiculous pain to have to edit.
This is the effective POM results, which show the WRONG path!
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jre6/../lib/tools.jar</systemPath> <optional>true</optional> </dependency>
sumber
Add this dependecy in pom.xml file. Hope this help.
In
<systemPath>
property you have to write your jdk lib path..<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.4.2</version> <scope>system</scope> <systemPath>C:/Program Files/Java/jdk1.6.0_30/lib/tools.jar</systemPath> </dependency>
sumber
Ended up using eclipse.ini fix:
openFile -vm (Your Java Home JDK here)
For example,
-vm C:\Java\JDK\1.6
.Had to also change JRE to JDK:
In Eclipse IDE go to:
sumber
-vm
, put the Java SDK path on the nect line, and place all of the newly added-vm
flag before the--vmargs
in theeclipse.ini
file.As other posters have stated the issue here has to do with the JRE that eclipse is using not being able to find the tools jar. I solved the issue by going in a bit of a different direction than what was stated above, and it was because of the way that my projects and environment.
Eclipse 4.5 requires at least Java 7 for runtime, so I've got my system setup to use a Java 8 JRE located at C:\java\jre1.8.0_45.
Next, I'm using a POM file that assumes that I'm running with a Java 6 JDK.
<profiles> <profile> <id>default-profile</id> <activation> <activeByDefault>true</activeByDefault> <file> <exists>${java.home}/../lib/tools.jar</exists> </file> </activation> <properties> <toolsjar>${java.home}/../lib/tools.jar</toolsjar> </properties> </profile> <profile> <id>osx_profile</id> <activation> <activeByDefault>false</activeByDefault> <os> <family>mac</family> </os> </activation> <properties> <toolsjar>${java.home}/../Classes/classes.jar</toolsjar> </properties> </profile> </profiles> <dependencies> <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6.0</version> <scope>system</scope> <systemPath>${toolsjar}</systemPath> </dependency> </dependencies>
I'm not allowed to change the POM file, so I had to do some jiggery pokery. I copied the tools.jar from my Java 6 JDK, created the directory C:\java\lib and pasted it there. I then restarted eclipse and cleaned my project. And VOILA errors are gone.
It's not an elegant solution, and I would think that the proper solution would be to change the way the POM is setup, but as I was not able to, this works.
sumber
I had the same problem on a Windows 7 and Eclipse 3.7 I managed to fix it by starting
You can start a cmd and launch eclipse like that, or you can edit your shortcut and add -vm "D:\JDK6\bin" as an argument in the "target section".
As a sidenote, I also tried to add -vm "D:\JDK6\bin" to eclipse.ini but did not work. And adding JRE6 will not work since it does NOT contain tools.jar in it's "lib" directory. Only JDK does.
sumber
After trying out all the above I was still having the same issue.
Then I tried the following,
Open a command prompt and typed java -version. It showed me a JRE version 1.8.
Open a command prompt and went to location of the JDK 1.7 bin directory and typed java -version. This time it showed correctly 1.7.
Then after digging at few places I found that apart from the above locations there are additional locations for Java runtime.
Registry
There is also a registry key where JRE location are specified under
I changed the entries here to point to the JDK 1.7
ProgramData
The directory "C:\ProgramData\Oracle\Java\javapath" is present in PATH environment variable and contains shortcuts to the java, javaw etc... The target for these shortcuts were all JRE 1.8. (This I think was the main problem) I changed the shortcuts to point to the correct JDK exe's.
Once all of this was done. I opened eclipse all the jdk.tools pom.xml errors disappeared.
sumber
I got this problem and it turns out that JBossDevStudio 9.1 on Windows is a 32-bit program. Eclipse, and thus the JBossDevStudio, does not work with the wrong type of JVM. 64-bit eclipse needs a 64-bit JVM, 32-bit eclipse needs a 32-bit JVM. Thus configuring Eclipse to run with my installed 64-bit JDK did not work.
Installing a 32 bit JDK and running Eclipse from that solved the problem.
At least for one of my projects, an other where I had tried to configure a runtime JDK in the Eclipse project properties is still broken.
sumber
I solved the problem by uninstalling JRE from my system and leaving JDK only. Reinstall JDK is not enough because Oracle JDK installer installs both JDK and JRE
BTW, it seems to me that this bug is responsible for troubles: java.home of the Eclipse JRE is used instead of the build JRE
sumber
In my case, I was executing Maven Build from Eclipse Run Configurations. Even after changing the default JRE configuration to point to JDK installation folder, the issue didn't get fixed for me. The reason is that there is a JRE tab in the Maven Build - Run Configuration (see the image below). And it was still pointing to my JRE installation. I changed it to point to JDK installation and then ran the Maven Build. This time, it worked. enter image description here
sumber
Let's understand why this issue happened:
Maven "mvn -version" command returns above output.
We can see maven gets the java runtime path as "C:\Program Files\Java\jre1.8.0_221" if you don't specify JAVA_HOME environment variable. And then maven assumes this path to be JAVA_HOME. That's why when building the application either from command prompt or any IDE, maven looks for tools.jar file in path "%JAVA_HOME%..\lib\tools.jar".
tools.jar is present in JDK path, so we need to mention this to maven before using it. Now a days machines are build with already available jre, but jdk is only required for development. This might be the reason why maven picks jre path automatically.
For more help, please read the code mvn.cmd available in maven installation path.
sumber
Problem is system is not able to find the file tools.jar
So first check that the file is there in the JDK installation of the directory.
Make the below entry in POM.xml as rightly pointed by others
<dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>C:\Program Files\Java\jdk1.8.0_241\lib\tools.jar</systemPath> </dependency>
then Follow the below steps also to remove the problem
1) Right Click on your project
2) Click on Build path
As per the below image, select the workspace default JRE and click on finish.
sumber
Changing 'Installed JREs' under 'Preferences -> Java -> Installed JRE' to JDK home worked for me.
FYI - Am using JDK 1.8.
sumber
If you are seeing this on newly installed/upgraded Operating system, it is just because JAVA_HOME is not set properly.
we need to set JAVA_HOME properly. For example on mac: if I want to use java version 1.8.0_261
export JAVA_HOME=`/usr/libexec/java_home -v 1.8.0_261`
sumber
Changing the relative location of
${java.home}/../lib/tools.jar
to the absolute path ofC:\Program Files\Java\jdk1.6.0_29\lib\tools.jar
works for me.You should only have to change it in the
playn/pom.xml
.Now for the playn-samples, Vladiator is right, that's too many pom files to change.
sumber