Java newbies know the usual procedure to compile and run Java program
- Open Notepad
- Write program(Optional) and save it as something.java
- Open CMD
- Run following command "set path=c:\program Files\Java\jdk1.6.0\bin"
- Navigate to your folder having something.java
- Run command "javac something.java"
- Run command "java something"
Thats a lot of procedure. Lets put Batch to help.
One more thing. I got to make folder "Lab_DATE" every lab and do respective practicals in them. Hence I created "start.bat" with following obvious commands.
mkdir Lab_
cd Lab_
cmd notepad
set path=C:\Program Files\Java\jdk1.6.0\bin
But it had a problem. The CMD window closed after executing last command. I needed it live after changing the path. Try it and you will know.
Help was the first thing that came to this computer engineers mind. Running "cmd /?" yields help. Thankfully there is /K switch that keeps terminal live after executing command. Finally tweaking start.bat to
mkdir Lab_
cd Lab_
cmd /C notepad
cmd /K set path=C:\Program Files\Java\jdk1.6.0\bin
did the trick... "Cut the crap" in my words.
I am still searching for some script that would write my Java program ;-)
No comments:
Post a Comment