In pom.xml for a java project, I lose the artifact jdk.tools:jdk.tools:jar:1.6 error

I think I know how to solve the problem, except: I don’t know where the specific version is mentioned in pom (I do not see it explicitly), and the solution I saw is to add this dependency:

<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 I would like to use com.oracle, and the jdk directory on Windows is jdk1.8.

So, is there a way to make pom want the version of tools that I have on my machine?

+6
source share
5 answers

I finally decided it right.

This happens when eclipse starts with the JRE instead of the JDK, because tools.jar not in the JRE. Based on this statement, try installing the JDK. If it is already installed, check Path that you have a JDK path, not a JRE path.

Be careful, recent java versions seem to add the following directory to Path : C:\ProgramData\Oracle\Java\javapath . It contains shortcuts that can reference a JRE. You will want to remove this and add the link to the JDK bin folder. (e.g. C:\Program Files\Java\jdk1.8.0_66\bin )

Please note that you may need to restart your computer for Path changes to be effective for running eclipse (I don’t understand why I should have, but I did).

Also note that Java updates are likely to add javapath to your PATH again. Therefore, you can not use automatic updates, but instead manually update the JDK and adapt your path after installation. It's a little heavy, but it does the job.

+18
source

For those who stumble over this in the future, read a more elegant solution:

Cause

This issue occurs in one of two scenarios:

  • You do not have JDK installed and not configured; or

  • You have JDK and JRE installed, and JRE becomes priority on the JDK path.

Decision

As explained in this link by the “Hadoop in the real world” command , you just need to add the dependency to tools.jar in your pom.xml file.

 <dependency> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId> <version>1.7.0_05</version> <scope>system</scope> <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath> </dependency> 

If the error repeats, just change the path on tools.jar to an absolute path, as shown below:

 <systemPath>C:/Program Files/Java/jdk1.8.0_65/lib/tools.jar</systemPath> 
+5
source

As I understand it, the best way to solve this problem is to add the following configuration to eclipse.ini to make sure that it uses a jdk copy of javaw when starting eclipse instead of a JRE copy that solves the problem and seems to be the correct approach to fix the problem

 -vm C:/Program Files/Java/jdk1.8.0_73/bin/javaw.exe 
+1
source

You can use the java.home environment variable:

 <dependency> <groupId>com.sun</groupId> <artifactId>tools</artifactId> <version>1.6</version> <scope>system</scope> <systemPath>${java.home}/lib/tools.jar</systemPath> </dependency> 

Please see: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#System_Dependencies

0
source
 <dependency> <groupId>jdk.tools</groupId> <artifactId>jdk.tools</artifactId> <version>1.7</version> <scope>system</scope> <systemPath>C:/jdk1.7.0_51/lib/tools.jar</systemPath> </dependency> 
0
source

Source: https://habr.com/ru/post/984103/


All Articles