can't run application using extension


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 11 of 11

Thread: can't run application using extension

  1. #1
    Join Date
    Oct 2002
    Posts
    23

    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.

  2. #2
    Join Date
    Nov 2002
    Posts
    138
    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

  3. #3
    Join Date
    Oct 2002
    Posts
    23

    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 ?

  4. #4
    Join Date
    Oct 2002
    Posts
    23

    Smile 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

  5. #5
    Join Date
    Apr 2003
    Posts
    10

    Cool 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

  6. #6
    Join Date
    Nov 2002
    Posts
    138
    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

  7. #7
    Join Date
    Oct 2002
    Posts
    23

    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.

  8. #8
    Join Date
    Oct 2002
    Posts
    23

    .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

  9. #9
    Join Date
    Oct 2002
    Posts
    23

    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.

  10. #10
    Join Date
    Oct 2002
    Posts
    23

    -jar command

    this is the jar command that was entered->
    jar -cmf bManifest.doc b.jar AreaApp.class RectangleArea.class

  11. #11
    Join Date
    Oct 2002
    Posts
    23

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center