¿Archivo por lotes para compilar y ejecutar archivos java?

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

preguntado el 01 de febrero de 12 a las 14:02

What goes there is exactly the same as what you would type manually on the command line to compile and run your Java code. -

2 Respuestas

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 Hormiga, 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" .

Respondido 01 Feb 12, 18:02

If you want to compile a single file este script será útil.

Respondido 27 Abr '13, 00:04

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.