I am dynamically compiling code in my client application. When I start the application with Java Web Start I get an exception. The exception only occurs when it is run through Java Web Start.
我在我的客户端应用程序中动态编译代码。当我使用Java Web Start启动应用程序时,我得到一个例外。只有在通过Java Web Start运行时才会发生异常。
//The exception
evolver.core.model.change.execution.ExecutionException: Compilation failed!
DynamicComparator.java:2: package evolver.core.model.i does not exist
import evolver.core.model.i.IDefaultObject;
^
DynamicComparator.java:9: cannot find symbol
symbol : class PropertyBag
location: class DynamicComparator
PropertyBag b2 = new PropertyBag(dob2);
^
The PropertyBag above should have been provided by the JNLPClassloader as it is part of one of the files that are downloaded by JWS
上面的PropertyBag应该由JNLPClassloader提供,因为它是JWS下载的一个文件的一部分
The code that causes the problem looks like this.
导致问题的代码如下所示。
public static int compile(String javaFileName) {
ByteArrayOutputStream os = new ByteArrayOutputStream();
PrintWriter w = new PrintWriter(os);
int res = com.sun.tools.javac.Main.compile(new String[]{"-d", "./", javaFileName}, w);
if (res != 0)
throw new ExecutionException("Compilation failed!" + "\n\n" + os.toString());
return res;
}
Any help will be very appreciated!
任何帮助将非常感谢!
1 个解决方案
#1
1
As it currently stands, you'll have to compile the code on the server. The server should not serve any code that might allow cross site attacks, so be very careful. The client can then use URLClassLoader.newInstance to load it.
就目前而言,您必须在服务器上编译代码。服务器不应该提供任何可能允许跨站点攻击的代码,所以要非常小心。然后,客户端可以使用URLClassLoader.newInstance来加载它。
#1
1
As it currently stands, you'll have to compile the code on the server. The server should not serve any code that might allow cross site attacks, so be very careful. The client can then use URLClassLoader.newInstance to load it.
就目前而言,您必须在服务器上编译代码。服务器不应该提供任何可能允许跨站点攻击的代码,所以要非常小心。然后,客户端可以使用URLClassLoader.newInstance来加载它。