简体   繁体   中英

Batch file for compiling and running java files?

I'm trying to create a drag and drop shortcut for compiling and running java files, rather than a command line interface. I'm thinking, I will create two batch files. But, what do I write to make the batch files use javac.exe or java.exe on what ever java files are dropped onto the batch files?


For the compiler batch file:

cd C:\Program Files\Java\jdk\bin     
javac [what goes here?]    
pause

For the run java batch file:

cd C:\Program Files\Java\jdk\bin
java [what goes here?]
pause

Don't bother; you would find these batch files useful for about one day. After that, your Java programs will contain multiple *.java files and depend on various *.jar files. Learn to use Ant , which can handle build processes from the simplest to the most complex.

But for completeness, the files DnD'd onto a batch file are available as if they were passed as arguments to the batch file at the command line, so your "[what goes here?]" is "%1", or, if you anticipate multiple files, "%1 %2 %3 %4 %5 %6 %7 %8 %9" .

如果要编译单个文件, 此脚本将很有用。

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