Thanks Jan,

this withing the javac-argument solved the problem:

<compilerarg value="-XDignore.symbol.file" />

This grants access to the restricted API!

Markus ;)

-----Ursprüngliche Nachricht-----
Von: Jan Matèrne (jhm) [mailto:apa...@materne.de] 
Gesendet: Dienstag, 20. Mai 2014 14:24
An: 'Ant Users List'
Betreff: AW: Cannot find symbol (CertAndKeyGen) with JDK8

I could reproduce the problem.
You are trying to refer to a private API, see 
http://www.oracle.com/technetwork/java/faq-sun-packages-142232.html

I could load the class via reflection (Class.forName) but not via direct 
reference.


While searching I found some hints:
https://svn.forgerock.org/opendj/trunk/opends/src/server/org/opends/server/u
til/Platform.java
      else
      { // Java 8 moved the CertAndKeyGen class to sun.security.tools.keytool
        certAndKeyGen = pkgPrefix + ".tools.keytool" + ".CertAndKeyGen";
      }
Here this class is used via reflection.


Also you get some responses via
http://stackoverflow.com/questions/23737746/cant-compile-with-ant-v1-9-4-and
-jdk8-cli


Adding all jars from java.home to the classpath doesnt work ... 
So it seems that you have to use reflection.


Jan


> -----Ursprüngliche Nachricht-----
> Von: Markus Wiesenbacher [mailto:markus.wiesenbac...@intrafind.de]
> Gesendet: Montag, 19. Mai 2014 12:56
> An: Ant Users List
> Betreff: AW: Cannot find symbol (CertAndKeyGen) with JDK8
> 
> - To be more specific, I am running this script from CLI:
> 
> <?xml version="1.0" ?>
> 
>       <project default="Compile">
> 
>               <target name="Compile">
> 
>                       <mkdir dir="classes"/>
>                       <javac
>                               srcdir="src"
>                               includes="**/*.java"
>                               destdir="classes"
>                               source="1.8"
>                               target="1.8"
>                               debug="false">
>                       </javac>
> 
>               </target>
> 
>       </project>
> 
> - This is the class:
> 
> import sun.security.tools.keytool.CertAndKeyGen;
> 
> public class AntProblem {
> }
> 
> - This is the error:
> 
> Buildfile: P:\workspaces\TEST\AntProblem\build.xml
> Compile:
>     [javac] P:\workspaces\TEST\AntProblem\build.xml:14: warning:
> 'includeantruntime' was not set, defaulting to 
> build.sysclasspath=last; set to false for repeatable builds
>     [javac] Compiling 1 source file to 
> P:\workspaces\TEST\AntProblem\classes
>     [javac] P:\workspaces\TEST\AntProblem\src\AntProblem.java:1: error:
> package sun.security.tools.keytool does not exist
>     [javac] import sun.security.tools.keytool.CertAndKeyGen;
>     [javac]                                  ^
>     [javac] 1 error
> 
> BUILD FAILED
> P:\workspaces\TEST\AntProblem\build.xml:14: Compile failed; see the 
> compiler error output for details.
> 
> Total time: 624 milliseconds
> 
> Best regards
> Markus
> 
> -----Ursprüngliche Nachricht-----
> Von: Markus Wiesenbacher [mailto:markus.wiesenbac...@intrafind.de]
> Gesendet: Montag, 19. Mai 2014 11:43
> An: user@ant.apache.org
> Betreff: Cannot find symbol (CertAndKeyGen) with JDK8
> 
> Hi,
> 
> I am trying to compile my classes (which make use of 
> sun.security.tools.keytool CertAndKeyGen) but I am always getting 
> "cannot find symbol". If I add the JRE-lib folder into my build-script 
> it works. I don´t know why, as the JDK-lib folder also contains the 
> rt.jar containing the needed classes.
> 
> With JDK7 it always worked without that. I am using Ant v1.9.4. Any 
> suggestions?
> 
> Thanks and best regards
> Markus
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional 
> commands, e-mail: user-h...@ant.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org For additional 
commands, e-mail: user-h...@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscr...@ant.apache.org
For additional commands, e-mail: user-h...@ant.apache.org

Reply via email to