-
can't run application using extension
i created a class file (File.java)and an application to run it in dir java. compiled both. created a jar file using - jar cvf0 myJARfiles.jar File.class -
removed File.class from java dir. ran application (AreaApp) with - java -classpath.;myJARfiles.jar AreaApp
made File.class into installed extension by placing it in dir c:\j2sdsk1.4.1_01\jre\lib\ext
jre should now be able to find and load File.class without
classpath in comm line. however - java AreaApp doesn't run.
error is no class def found for File.class. when i display myJAR.jar contents it shows File.class. if i try to run appliction in dir c:\j2sdk1.4.1_01\jre\lib\ext an error says on class definition found for AreaApp. i'm checking how the extension mechanism works.
thanks for your help.
-
did you create a manifest for your jar executable? without this it won't run. manifest is a file with you main class's name in it.
e.g
in file named myManifest ( it could be with or w/out extension it doesn't matter ) write:
Main-Class: name_of_main_class
now to make a jar:
jar -cfm name_of_jar name_of_manifest_file name_of_class/es
-
manifest
thanks for your help. i thought a manifest was created by default when i made a .jar file. so why should i make another ?
-
manifest file
myManifest {
Main-Class: AreaApp}
c:\java>jar -cfm a.jar myManifest RectangleArea.class
error-java.io.IOException: invalid manifest format
at java.util.jarManifest.read<Manifest.java:186>
at java.util.jar.manifest.<init><Manifest.java:52)
at sun.tools.jar.Main.run<Main.java:124>
at sun.tools.jar.Main.main<Main.java:904)
source of AreaApp and RectangleArea files-> http://java.sun.com/docs/books/tutor...s/install.html
thanks
-
JAR wizard
One great download for this is the JAR Wizard avalible at Java Boutique. It will save you a bunch of keystrokes and just as many headaches. It is slick. If you have a good connection it's worth it (7 Meg).
It also makes a shortcut for you.
Let me know if you can't find it or need a copy.
Hutch
-
yes, it does make it's own manifest,but you have to specify to jar which of your classes is main. you don't need the {} in the manifest. follow the format below. and since you have two classes, you can specify both names in the arguments, or if your .java files are in its own folder then you can make use of the * wildcard.
ex.:
jar -cfm MyJar.jar MyManifest RectangleArea.class AreaApp.class
-
jar files
thanks for that tip cary, i will check on the JAR WIZARD software. i did not include {} in my manifest file lex. i used them here just for clarity. i will add AreaApp.class to .jar file when i have a chance later. thanks all for your help.
-
.jar file
i still get 'invalid manifest format' error with command-> jar -cfm a.jar myManifest file1.class file2.class-. it is said that myManifest file should end with a newline character. should this be- \n ? also do i need in myManifest-
Manifest-Version: 1.0
name: AreaApp.class
name: RectangularArea.class
-
myManifest file
file myManifest was created in Notepad. printed file and got this ->
myManifest
Main-Class: AreaApp
-it seems that Notepad is placing the file name at the top of the manifest file causing invalid file format error for, jar -cmf myManifest ........ command. wrote manifest file in MS Word and saved in dir java. printed file and did not get file name at top of myManifest file. displayed file contents and got strange characters instead of plain english. had to add .doc extension to jar -cmf myManifest.doc a.jar ...... command or else got, file could not be found, error. also got this error for the command -> java.io.IOException: line too long- .
thanks for your suggestions.
-
-jar command
this is the jar command that was entered->
jar -cmf bManifest.doc b.jar AreaApp.class RectangleArea.class
-
i've finally got it
wrote myManifest file in DOS file editor of my win2000pro system, command edit, at command prompt. jar -cmf myManifest a.jar ........, created a.jar file. java AreaApp executed and gave the correct output. it seems Notepad and MS Word were corrupting myManifest file. downloaded JAR Wizard and am figuring how to use it. thanks to all who helped.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks