Tuesday, September 30, 2008

Compile and Execute Java Files using a bat file

I started to learn java and I needed a fast way to compile and execute small java programs that I wrote on notepad or my favorite Notepad++ and command prompt is considered a very fast way if you know that you Don't have to rewrite the command each time you want to compile or run a java file , you can just write them in a .bat file and execute all this commands with a double click.

All what you have to do is to write the commands in a text file and save it with .bat file extension.

An example of .bat file that compiles and execute a java file in my desktop :

@echo off

rem delete the old class file to avoid executing it
rem if there was an error in the new java file
cd C:\Documents and Settings\Ahmed Kotb\Desktop\
if exist a.class del a.class

rem Compile the java file(s)
cd C:\Program Files\Java\jdk1.6.0_04\bin\
javac "C:\Documents and Settings\Ahmed Kotb\Desktop\a.java"

rem Execute
cd C:\Documents and Settings\Ahmed Kotb\Desktop\
if exist a.class java a

pause

any comments or questions are welcomed
Hope this was useful.

Tuesday, September 2, 2008

Happy Ramadan !

for those few who are reading this humble blog thank you :D and Ramadan Kareem.

ramdan-kareem

5 years of kotbcorp

Two days ago this blog completed its 5th year  :). So congratulations to my self and Thanks for the few followers that have been here for ...