How do you address the issue of a missing tools.jar in a JDK in Mac OS X?

后端 未结 7 1107
醉梦人生
醉梦人生 2020-12-16 16:24

From my searching, I found supporting information here: Java Development Guide for Mac OS X

tools.jar does not exist. Classes usually lo

7条回答
  •  旧巷少年郎
    2020-12-16 16:44

    I faced the same problem, and resolved it differently.

    • First check that the java_home is set as /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents and not /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home
    • Add the cobertura plugin, make sure systemPath is correctly ref the location of classes.jar

          
              org.codehaus.mojo
              cobertura-maven-plugin
              2.6
              
                  
                      com.sun
                      tools
                      1.6
                      system
                      ${java_home}/Classes/classes.jar
                  
              
          
      
    • Add the dependency and exclude tools

          
          org.codehaus.mojo
          cobertura-maven-plugin
          2.6
          test
          
              
                  com.sun
                  tools
              
          
      
      
    • Finally add the following profiles

      
      
          standard-jdk
          
              
                  ${java_home}/Home/lib/tools.jar
              
          
          
              ${java_home}/Home/lib/tools.jar
          
      
      
          apple-jdk
          
              
                  ${java_home}/Classes/classes.jar
              
          
          
              ${java_home}/Classes/classes.jar
          
      
      

    Now run maven and it should successfully generate the Cobertura reports!

提交回复
热议问题