How to compile Java and create executable Jar file

First of all, of course, you need to install JDK to compile your Java program before using my batch file below.
I made this batch file and saved it in C:\Windows\ folder. Now open command prompt window from any folder that has your java program and run the batch file with your java program name. For example, if you saved the batch file as j.bat and your java program’s name is, simply write ‘j myJava’ (without quotation marks) in the command prompt window and enter.

Here is the batch file.

path C:\Program Files\Java\jdk1.6.0_24\bin;%path%
echo Main-Class: %1>manifest.txt
jar cfm %1.jar manifest.txt *.class


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s