简体   繁体   English

雄猫。 Java运行时编译

[英]Tomcat. Java runtime compile

I create web application where user can input Java source code in input area and send it to server.我创建了 Web 应用程序,用户可以在其中输入 Java 源代码并将其发送到服务器。 After that I create file User.java (by default this file created in C:\\Tomcat-8.0.36\\bin ) and compile it in runtime through Runtime.getRuntime().exec("javac User.java") .之后我创建文件User.java (默认情况下,这个文件在C:\\Tomcat-8.0.36\\bin )并在运行时通过Runtime.getRuntime().exec("javac User.java")编译它。 It's successfully compile.它编译成功。 Then I try to run in Runtime User.class through Runtime.getRuntime().exec("java User") , but I get error message: "Could not find or load main class User" .然后我尝试通过Runtime.getRuntime().exec("java User")在 Runtime User.class中运行,但我收到错误消息: "Could not find or load main class User" Although I can correct run this file with the help of cmd of this directory C:\\Tomcat-8.0.36\\bin .虽然我可以在这个目录C:\\Tomcat-8.0.36\\bin的 cmd 的帮助下正确运行这个文件。 Also I try to run bat file from code (for example mspaint - successfully run paint - it is mean that correct workspace), but when I run bat file with " java User " - it is failed.此外,我尝试从代码运行 bat 文件(例如 mspaint - 成功运行 Paint - 这意味着正确的工作区),但是当我使用“ java User ”运行 bat 文件时 - 它失败了。

Any ideas?有任何想法吗? Thanks.谢谢。

Perhaps you should try "java -cp . User" that why you're making sure that User class is on classpath - by -cp .也许您应该尝试“java -cp . User”,这就是为什么您要确保 User 类在类路径上 - 通过 -cp 。 you're putting current folder on the cp.您将当前文件夹放在 cp 上。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在tomcat上运行的Java应用程序。 无法通过ajp访问。 - java application running on tomcat. Unable to access over ajp. 我需要Tomcat上的JAX-WS运行时。 将“ jax-ws / lib / *”放入“ tomcat / lib”是否可以? - I need JAX-WS runtime on Tomcat. Is it ok to put “jax-ws/lib/*” to “tomcat/lib”? Tomcat。 导入 class 时出现 ClassNotFoundException - Tomcat. ClassNotFoundException on importing class 使用带有附件文件的Java发送邮件,该附件文件可用于Glassfish服务器,但不能与tomcat一起使用。 我该怎么办? - Sending mail using java with attachment file working with Glassfish server but not with tomcat. What Should I do? 带有Jersey和Tomcat的Java Web Services。 ¿当Web服务停止时如何停止所有线程? - Java Web Services with Jersey and Tomcat. ¿how to stop all the threads when the web service is stopped? 无法从在 Tomcat 中运行的 Guava r08 加载类。 无法从源代码编译。 缺少 javax.annotations - Cannot load classes from Guava r08 running in Tomcat. Cannot compile from source. Missing javax.annotations 在运行时编译Java代码 - Compile java code at runtime 在Tomcat上安装游戏。 纽布在这里 - Installing a game on Tomcat. Newb here 在tomcat中部署的问题。 在本地tomcat中工作正常。 在生产tomcat中抛出空指针异常 - issue with deployment in tomcat. Works fine in local tomcat. throws null pointer exception in Production tomcat 使用Java 1.8 for Tomcat7进行编译? - Compile with java 1.8 for Tomcat7?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM