This ia the simpest way to create jar files....
How to create a jar file - by Tanul Karkare:
create a file MANIFEST.MF having 2 lines:
Manifest-Version: 1.0
Main-Class: path of ur main class file..
create a folder META-INF in ur application dir.
put this MANIFEST.MF into that.
execute the command:
jar cvfm xyz.jar META-INF/MANIFEST.MF *.class
to create an executable jar file.
just that's it.
-----------
Take an example:
create a folder test(any name will do)
create a file TestJar.java in that:
import javax.swing.*;
class TestJar extends JFrame
{
public static void main(String[] args)
{
TestJar tj = new TestJar();
tj.setSize(200, 200);
tj.setVisible(true);
tj.show();
}
}
compile this file , test with java command.
it should show a window.
create a manifest file as above inside meta-inf folder (which is inside test folder) with content:-
Manifest-Version: 1.0
Created-By: Tanul
Main-Class: TestJar
execute the command inside test folder:(test.jar can be any name)
jar cvfm test.jar META-INF/MANIFEST.MF *.class
ur executable jar is ready.
double click on it and it will show u a window.
u can give this to anybody without letting him have ur source files.
No comments:
Post a Comment