Hosting the Java compiler in an applet or in Google AppEngine?

为君一笑 提交于 2019-12-08 02:01:56

问题


Searching the web I've found that the Javac compiler is written in Java, and I also peeked at the source on Sun's site. The source is quite big and I couldn't make any headway on it. Also the Eclipse project has a compiler embedded inside, but who could touch its source code ;-).

So I thought I'd throw a couple of questions your way:

  1. Could the Java compiler be hosted in an Applet?
  2. Could the Java compiler be made to work on GAE, with dynamic loading of the resulting class files from the datastore?

回答1:


Yes, the compiler as such is really just a normal Java application (except that it usually brings its own native launcher, but that's not required).

So you can easily run it within an Applet or inside GAE.

However that won't really help too much, because if you want to actually run the produced classes, then you'd need to play with ClassLoader instances which is not allowed in (unsigned) Applets and probably not allowed in GAE.




回答2:


..Could java compiler be hosted in an applet?

Only if you add the tools.jar to the runtime class-path of the applet. See Add the compiler to the application's runtime classpath in the STBC help for details.

..Could java compiler be made to work on GAE, ..

Not sure, though note that someone seems to have registered a Google app. by the name of 'javacompiler'. ;)



来源:https://stackoverflow.com/questions/5166208/hosting-the-java-compiler-in-an-applet-or-in-google-appengine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!