简体   繁体   中英

How to run a specific java file present in eclipse using batch file?

我必须创建一个批处理文件,以便它应调用eclipse中存在的特定Java文件。

Suppose, your java file is in path:

D:/WorkDir/Java/Filename.java

Then your bat file (say abc.bat ) should be,

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

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 .

Runtime rn=Runtime.getRuntime();
Process pr=rn.exec(path); 

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