• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

Invoking javac ...

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,
Is there a way to invoke the java compiler internally from a program? What I want to do is create java code dynamically and give the user some class files.
OK, a nice way would be to find the path to JAVA_HOME and invoke the compiler externally.
On the other hand I guess I maybe have to distribute a compiler with my app (for the users who have only JRE installed). Can I distribute SUN's javac? If yes what files will I have to include apart from the compiler file (assuming different versions for different platforms)?
Tnx,
Tom.
 
Ranch Hand
Posts: 152
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It is possible. Look at the Apache Jakarta Ant build tool.
http://jakarta.apache.org/ant/index.html
It is an example of a program that does just that.
As for bundling javac, you should check with Sun to be
sure that you are on the right side of the law.
HTH,
Joe
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Distributing javac is usually a pretty big no-no, from what I understand... How about this solution?
Running the program from a server with the JDK installed, write the Java file on the fly with a text file. Then, using Runtime.exec(), call the compiler to compile the file on the server. Once compiled, you simply need to link the class files to a web page, and the users could d'load them from there. Does this make any sense?
-Andrew
 
Hold that thought. Tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic