[英]How to run a specific java file present in eclipse using batch file?
我必须创建一个批处理文件,以便它应调用eclipse中存在的特定Java文件。
Suppose, your java file is in path: 假设您的java文件在路径中:
D:/WorkDir/Java/Filename.java
Then your bat file (say abc.bat
) should be, 然后,您的bat文件(例如
abc.bat
)应该是,
d:
cd WorkDir/Java
java Filename
Below is an example, where you have commands to set java class path and include additional jar files and pass arguments to Filename.java 下面是一个示例,您在其中具有设置Java类路径并包括其他jar文件并将参数传递给Filename.java的命令。
set classpath=%classpath%;c:\MY APPS\lib\log4j.jar;
d:
cd WorkDir/Java
java Filename arg1 arg2 arg3 etc
To call the bat file from java, you need to use runtime.exec as below and in this link . 要从Java调用bat文件,您需要使用以下链接中的 runtime.exec。
Runtime rn=Runtime.getRuntime();
Process pr=rn.exec(path);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.