1 Reply Latest reply: Oct 27, 2011 1:09 AM by EJP RSS

    Adding a java file to a jar and compiling it

    VANPERSIE
      Hi
      I have added a java file to a jar package
      C:\Program Files\Java\jdk1.5.0_22\bin>jar cvf swing-layout-1.0.2.jar NewJFrame.java
      
      added manifest
      adding: NewJFrame.java(in = 7751) (out= 1435)(deflated 81%)
      When I extracted the jar package swing-layout-1.0.2.jar the added file not found!
      Can someone tell me why?
      and I have second question

      when I added the java file manually to the package (after extracting ) and compiled the java file,it gives me an error
      C:\Program Files\Java\jdk1.5.0_22\bin>javac -classpath "C:\Program Files\Java\jdk1.5.0_22\bin\org\jdesktop\layout" NewJFrame.java
      It gives me an error
      NewJFrame.java:35: package org.jdesktop.layout does not exist
      Can someone help please.
        • 1. Re: Adding a java file to a jar and compiling it
          EJP
          I have added a java file to a jar package
          Why? That's not where they normally live.
          When I extracted the jar package swing-layout-1.0.2.jar the added file not found!
          Extracted it how?
          Can someone tell me why?
          and I have second question

          when I added the java file manually to the package (after extracting)
          What package?
          C:\Program Files\Java\jdk1.5.0_22\bin>javac -classpath "C:\Program Files\Java\jdk1.5.0_22\bin\org\jdesktop\layout"
          That's the strangest classpath I've ever seen. Problems:

          1. Directories under the JDK are the last place you should put your own source code.
          2. A classpath is a list of places where classes can be found according to their package structure. If your class is in the package org.desktop.layout, the directory containing org/desktop/layout should be in the classpath, not org/desktop/layout itself.
          NewJFrame.java:35: package org.jdesktop.layout does not exist
          It's not found on the classpath for the reason(s) above.