Post a Job  |   Ask a Question?   |   Already registered? login or register
Ramakanth reddy
19/05/2015 01:13 PM

ClassLoader: I created manifestfile successfully..those who want may see it

manifest file (executable file)
Spam    7 Comments

19/05/2015 14:19:02
first create one class with main(),compile it .create one folder with any name ,and place here your .class file which contains main() and create folder with name META-INF beside to our .class file. Now inside META-INF create a text file with name .In that text file give our main class name as following. Main-Class: our fully qualified class name(which contains main()). note: Here we should give space between "Main-Class" and our class name. Let me explain it with example clearly: ========================= #STEP1# let me write one class public class Test { public static void main(String[] args) { System.out.println("manifest file has been created "); } } #STEP2# let me compile this class c:\>javac Test -->press enter now we got .class file #STEP3# now create one folder where ever you want, with any name. let me create a folder with name APP1. inside APP1 folder create another folder with name META-INF. Beside to the META-INF folder place your .class i.e Test.class. Inside META-INF folder create text file with name MANIFEST.MF . inside MANIFEST.MF text file we should give like following line Main-Class: Test5 note-1:if class has package,we should give class name with the package. note-2: Here space should be there between "Main-Class" and Test5 #STEP4# [creation of executable(manifest file)] assume our APP1 folder is in directory D:\APP1 go to that directory D:\APP1> now give following command here D:\APP1>jar -cvfm abc.jar META-INF\MANIFEST.MF Test3.class ==>press enter "now u get following msg if creation of manifest file is success" added manifest adding: Test3.class(in = 506) (out= 327)(deflated 35%) now open your APP1 folder Inside APP1 folder you can find one jar file with name abc.jar (it contains java tea cup logo on it) With this "creation of executable " is over #LAST STEP#[Execution of executable file] Now Go to the command prompt go to the APP1 location D:\APP1>java -jar abc.jar press enter now we see o/p as following manifest file has been created this is what we have given in our Test class ,inside System.out.println to be displayed . I HOPE I EXPLAINED VERY WELL >> THANK YOU TO OUR SRIMAN SIR ..BECAUSE HE IS EXPLAINING VERY WELL.TANK U SIR.

19/05/2015 14:28:50
Even we can create executable file with eclipse &&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& Go to Eclipse id-->Create ur project--->Right Click on project---> Export--->Java-->jar file--->Next-->Give the Export Location with jar name--> Next--->Next--->Select generate manifest file and Give the class name with pkg name which holds main method -->Finish =>This will create the jar. Inside the the jar with in the META-INF manifest file will be there

19/05/2015 14:41:25
This is my way: C:work/> | |-MANIFEST.MF Create a file as below: public class Test { public static void main(String[] args) { System.out.println("Hello-World-Test"); new Test().getLoader(); } public void getLoader() { System.out.println("Loaded By: "+this.getClass().getClassLoader()); } } Now create a MANIFEST.MF and its content as below: Main-Class: Test// press enter at this place To create jar with above manifest file and Test.class: C:work/>javac // compilation C:work/>jar cvfm app.jar MANIFEST.MF *.class // jar creation Delete the Test.class from C:work/> C:work/>java -jar app.jar // executing the jar Thanks to Sriman Sir.He never thinks bad for us

19/05/2015 23:50:42
Hai R.k reddy as above u said how create the manifest file na i created in the same way but it is giving classNotFoundError.. what is the problem do u think..... my directory: D:javaf:app1:/>jar -cvfm abc.jar META-INF\MANIFEST.MF Manifest.class it is giving classNotFoundError...........

21/05/2015 07:55:26
@madumohan--make sure that do you have package in your class.If you Package you Should take care while creating executablejar file. assume your class is in package then command is jar -cvfm abc.jar META-INF\MANIFEST.MF com\mf\Manifest.class here we should not use dot(.) while mentioning package rather we should use \ (backward slash).. still you didn't get then mail me your app1 folder .i will solve and send to NOTE: here we can use either upper/lower case while naming the manifest file ex ----->valid ex:MANIFEST.MF------->valid

21/05/2015 08:05:34
NOTE: here we can use either upper/lower case while naming the manifest file ex: manifest.MF--->valid ex:>valid ex : ----->valid ex: MANIFEST.MF------->valid i checked all these naming conventions .all are working fine .So there is problem with name of manifest.MF.

21/05/2015 08:07:09
my mail id: if u dont get ,mail me that app1 folder ,i would like to solve it.

Languages :