简体   繁体   中英

Can java code be compiled on a server?

I would like to add a "program creator" to my website. The idea is that non-programmers could use a interactive graphical editor on my website to create a java program and then download the completed jar file. Similar things have been done many times, but as far as I know there aren't any java ones that let you download the jar.

Is it possible to set up a java compiler on a server that could be used to compile the programs users create and them package them into a jar which users could download? If it is possible can it be done of a hosted server such as GoDady?

Thanks!

Yes, it should be. But you need a server on which you have enough control to get sure you got a JDK, not only a JRE. And that's gonna be the most difficult part...

If you can get that, afterwards, you can use any scripting language to invoke javac, the compiler. This could even be done within a servlet that would compile some generated java source files.

Take a look at http://docs.oracle.com/javase/6/docs/api/javax/tools/JavaCompiler.html , it is Java Compiler's API. You can write a Java program that compiles other Java programs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM