It is a really simple thing but I cannot get my head around it. I have looked at plenty of StackOverFlow post and as well as on internet.
My goal is to create a .bat whi
I just made a simple batch script that takes a file name as an argument compiles and runs the java file with one command. Here is the code:
@echo off
set arg1=%1
shift
javac -cp . %arg1%.java
java %arg1%
pause
I just saved that as run-java.bat and put it in the System32 directory so I can use the script from wherever I wish.
To use the command I would do:
run-java filename
and it will compile and run the file. Just make sure to leave out the .java extension when you type the filename (you could make it work even when you type the file name but I am new to batch and don't know how to do that yet).