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 myJava.java, 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%
javac.exe %1.java
echo Main-Class: %1>manifest.txt
jar cfm %1.jar manifest.txt *.class
%1.jar

Advertisements
About

Opto-mechatronic Engineering scientist.

Tagged with:
Posted in Computer

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

February 2011
S M T W T F S
« Dec   Mar »
 12345
6789101112
13141516171819
20212223242526
2728  
Archives

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 11 other followers

%d bloggers like this: