This discussion is archived
4 Replies Latest reply: Mar 2, 2010 2:59 PM by 843810 RSS

export compiler into a runnable jar

843810 Newbie
Currently Being Moderated
Hey guys,
I'm not sure about the title... I have an object that uses the JavaCompiler object, which I get:
     private final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
I tried to export the project which is defined to work with the JRE 1.6 in Eclipse, into a runnable jar, and when I run the jar I get null from the ToolProvider, in Eclipse all work fine and the compiler is there.

How can I use the JRE 1.6 instead of the JDK in my application?

Adam.
  • 1. Re: export compiler into a runnable jar
    608410 Newbie
    Currently Being Moderated
    Adam,

    tools.jar, which contains the compiler and other development tools, does not ship with the JRE. that is why you can't find a System compiler.

    I am not sure about licensing concerns, but from a purely technical point of view, you would need to deploy tools.jar from a JDK) to each JRE, or as part of your app, in an appropriate place (of which there are probably around a handful of different ways that would all work).

    Bruce
  • 2. Re: export compiler into a runnable jar
    843810 Newbie
    Currently Being Moderated
    I just feel the need to ask this in my own words to understand, so from a purely technical point of view, I can extract the tools package out of the JRE Jar file and to Jar it in a different Jar file, where each class has its full path name, and to add it to the build path of my application?

    Adam.
  • 3. Re: export compiler into a runnable jar
    608410 Newbie
    Currently Being Moderated
    No.

    from a purely technical point of view, on my windows box (as an example)

    C:\Program Files\Java\jdk1.6.0_18\lib contains a file tools.jar

    to run with a jre

    copy that tools.jar to (for example)

    C:\Program Files\Java\jre6\lib

    the the jre will be able to find the compiler (which is in tools.jar)

    Bruce
  • 4. Re: export compiler into a runnable jar
    843810 Newbie
    Currently Being Moderated
    Thanks Bruce,

    Isn't this remarkable, everything works perfectly(from a technical point of view of course), really appreciate all your help. all of you guys on all the threads I want to thank you all for all your help, So thank you.

    Adam.