Need help: how to make a package into a jar file?

I tried to make a package into a jar file by using:
jar cf a.jar packagedirectory
But when I import one class of this package in an other application, by using:
javac -cp path\a.jar; app.java
the compliler can not find the calss.
The interesting thing is if I do not put the package into the jar file, it works well.
Here is my sample code under path D:\b\b1
package b1;
public class Son
     int x = 10;
     public Son(){
     public int getX(){
          return x;
and the application code under path d:\b
import b1.Son;
public class Father
     public Father(){
     public static void main(String[] args)
          Son son = new Son();
          System.out.println("Hello World!"+son.getX());
Thanks for any advise.
Xin Cheng

You must make sure that you are in the right directory
when you do your jar command to create the archive.
[home/trejkaz/proj/test/classes]% jar -cf a.jar
path/to/package/*.class
Thank you very much.
Yes, I did as what you said, but it does not work.
Here is what I did:
1. Edit Father.java in D:\b
2. Edit Son.java in D:\b\b1
3. Compile Son.java
4. Complie Father.java
5. Make the a.jar by
command jar cf a.jar D:\b\b1\ (I cheked the content of the a.jar, it seems right.)
a.jar is in directory D:\b
6. Delete Son.class in D:\b\b1
7. Run Father.class by
command: java -classpath D:\b\a.jar; Father
error message is: Exception in thread "main" java.lang.NoClassDefFoundError: b1/Son
at Father.main(Father.java:11)
What is the problem?
Thanks again.

Similar Messages

  • How to add a directory into a jar file

    Hi, guys, I want to add a package into a jar file. For example, my dirctory structrue
    is org/test/, all files locate in the directory test, in org.test package. I want to
    add the package into a jar file, test.jar. I use "java -cvf test.jar -C org/test/ .
    But it says "jar: no match". How can I solve it.
    thanks

    Instead of 'java', use 'jar'.
    All in all, try this: jar cvf test.jar -C org/test/*.class.
    Have a nice day!

  • I need help. how to make vertical drop down menu

    I need help. I want on my site to make navigation as such on this site http://www.website24.eu/einstieg/. if you can help me and explain how?

    like this http://www.jqueryrain.com/?3khGEoMY

  • I need help how to make emails into outide folders for storage?

    I need to back up emails as folders in order to save for the new computer?  Is there a way to do this though mobile me?

    Hi Grant
    I think I've solved my problem
    I will get the emails off the server when I switch to the new computer
    I have both macmail & entourage
    I'm upgrading from a G5 to the new imac
    Thank you, also do you know someone who is an app developer for the ipad?

  • Need Help :  How to make particular Record  in Bold

    Hi Frnds,
    I am facing the problem to resolve the following issue....... Plz... help me out .........
    I am displaying the payslip information (Elements Information ) in a Table.
    In the table , i am showing the "DEDUCTIONS TOTAL"  , "EARNING TOTAL" and "NET PAY"
    Now, i have to display the DEDUCTIONS TOTAL, EARNINGS TOTAL  AND NET PAY in BOLD
    plz... help me out .........
    Regards,
    Jaya

    Hello
    did you try to use EL in the Attribute inlineStyle of the cell you want to style:
                              inlineStyle="#{row.Salary.value>200?'color: Red; background-color: Green; font-size: 30pt; font-weight: bolder;':''}"
    here is the full page script to display data from employees table in HR schema:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page contentType="text/html;charset=windows-1252"%>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces" prefix="af"%>
    <%@ taglib uri="http://xmlns.oracle.com/adf/faces/html" prefix="afh"%>
    <f:view>
      <afh:html>
        <afh:head title="untitled1">
          <meta http-equiv="Content-Type"
                content="text/html; charset=windows-1252"/>
        </afh:head>
        <afh:body>
          <af:messages/>
          <h:form>
            <af:table value="#{bindings.EmployeesView1.collectionModel}" var="row"
                      rows="#{bindings.EmployeesView1.rangeSize}"
                      first="#{bindings.EmployeesView1.rangeStart}"
                      emptyText="#{bindings.EmployeesView1.viewable ? \'No rows yet.\' : \'Access Denied.\'}">
              <af:column sortProperty="EmployeeId" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.EmployeeId}">
                <af:inputText value="#{row.EmployeeId}"
                              required="#{bindings.EmployeesView1.attrDefs.EmployeeId.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.EmployeeId.displayWidth}">
                  <f:convertNumber groupingUsed="false"
                                   pattern="#{bindings.EmployeesView1.formats.EmployeeId}"/>
                </af:inputText>
              </af:column>
              <af:column sortProperty="FirstName" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.FirstName}">
                <af:inputText value="#{row.FirstName}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.FirstName.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.FirstName.displayWidth}"/>
              </af:column>
              <af:column sortProperty="LastName" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.LastName}">
                <af:inputText value="#{row.LastName}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.LastName.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.LastName.displayWidth}"/>
              </af:column>
              <af:column sortProperty="Email" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.Email}">
                <af:inputText value="#{row.Email}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.Email.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.Email.displayWidth}"/>
              </af:column>
              <af:column sortProperty="PhoneNumber" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.PhoneNumber}">
                <af:inputText value="#{row.PhoneNumber}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.PhoneNumber.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.PhoneNumber.displayWidth}"/>
              </af:column>
              <af:column sortProperty="HireDate" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.HireDate}">
                <af:inputText value="#{row.HireDate}"
                              required="#{bindings.EmployeesView1.attrDefs.HireDate.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.HireDate.displayWidth}">
                  <f:convertDateTime pattern="#{bindings.EmployeesView1.formats.HireDate}"/>
                </af:inputText>
              </af:column>
              <af:column sortProperty="JobId" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.JobId}">
                <af:inputText value="#{row.JobId}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.JobId.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.JobId.displayWidth}"/>
              </af:column>
              <af:column sortProperty="Salary" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.Salary}">
                <af:inputText value="#{row.Salary}"
                              required="#{bindings.EmployeesView1.attrDefs.Salary.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.Salary.displayWidth}"
                              inlineStyle="#{row.Salary.value>200?'color: Red; background-color: Green; font-size: 30pt; font-weight: bolder;':''}">
                  <f:convertNumber groupingUsed="false"
                                   pattern="#{bindings.EmployeesView1.formats.Salary}"/>
                </af:inputText>
              </af:column>
              <af:column sortProperty="CommissionPct" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.CommissionPct}">
                <af:inputText value="#{row.CommissionPct}"
                              required="#{bindings.EmployeesView1.attrDefs.CommissionPct.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.CommissionPct.displayWidth}">
                  <f:convertNumber groupingUsed="false"
                                   pattern="#{bindings.EmployeesView1.formats.CommissionPct}"/>
                </af:inputText>
              </af:column>
              <af:column sortProperty="ManagerId" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.ManagerId}">
                <af:inputText value="#{row.ManagerId}"
                              required="#{bindings.EmployeesView1.attrDefs.ManagerId.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.ManagerId.displayWidth}">
                  <f:convertNumber groupingUsed="false"
                                   pattern="#{bindings.EmployeesView1.formats.ManagerId}"/>
                </af:inputText>
              </af:column>
              <af:column sortProperty="DepartmentId" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.DepartmentId}">
                <af:inputText value="#{row.DepartmentId}"
                              required="#{bindings.EmployeesView1.attrDefs.DepartmentId.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.DepartmentId.displayWidth}">
                  <f:convertNumber groupingUsed="false"
                                   pattern="#{bindings.EmployeesView1.formats.DepartmentId}"/>
                </af:inputText>
              </af:column>
              <af:column sortProperty="DeptName" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.DeptName}">
                <af:inputText value="#{row.DeptName}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.DeptName.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.DeptName.displayWidth}"/>
              </af:column>
              <af:column sortProperty="EmpVideo" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.EmpVideo}">
                <af:inputText value="#{row.EmpVideo}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.EmpVideo.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.EmpVideo.displayWidth}"/>
              </af:column>
              <af:column sortProperty="Nationality" sortable="false"
                         headerText="#{bindings.EmployeesView1.labels.Nationality}">
                <af:inputText value="#{row.Nationality}" simple="true"
                              required="#{bindings.EmployeesView1.attrDefs.Nationality.mandatory}"
                              columns="#{bindings.EmployeesView1.attrHints.Nationality.displayWidth}"/>
              </af:column>
            </af:table>
          </h:form>
        </afh:body>
      </afh:html>
    </f:view>
    Best Regards,
    Ahmad Al-Zamer

  • Need help -how to use a GUI to compile a file

    hello peeps,
    I have this problem, let's get directly into it, i have a program that has GUI with a Text Area that im going to copy a text file into it (using JFileChooser FileReader and readLine() ...) so i have radio buttons like (view, compile and execute) and an OK button to get the selected option, what i want to know is how to compile the file that is in the text area, like how to get to the MS-dos console and javac to start. i hope this description is clear, and i'll be very appreciative for any help!

    thanks for your response, but its not working it keeps on throwing IOException, i tried to put a direct string into it like (Runtime.getRuntime().exec("javac MyClass.java"); and same thing happend. Am i missing something? like is there something to add before calling that line of code? i did import Runtime
    ok here is how my code looks like:
       if(compile.isSelected())
                       try
                       //name of the file im pasting into the text area  
                       String filename = file.getName();
                       Runtime.getRuntime().exec("javac" + filename);
                       catch (IOException e)
                         System.out.println("error compiling program");
                   }

  • How to add my class into rt.jar file?

    Hi, everyone!
    I am using WinRAR to extract the package rt.jar and added
    my class file to javax folder. Then I use jar c0vf to create
    a package. After that, I restart my WSAD4.0.2. But it seems
    that WSAD4.0.2 can not be started. (It stops at the welcome
    screen for a long time.)
    Anything wrong I have made? How to resolved the reouble?
    Cheers,
    George Ma

    Thanks!
    Do you know how to add .class file to a project of WSAD4.0.2?
    I use CLASSPATH, but always failed in IDE. But it works in
    command line environment. I want to use some classes in a
    .class file.
    Can you help?
    Cheers,
    George

  • How to make a package and import it later

    Hi folks,
    this is a very basic question but it is not working to me so i will appreciate your comments.
    I had programmed many classes that are going to be used in many projects so they must be part of a library. Tell me whether or not this procedure is correct ?
    Compile those classes into .class files. Create a package with the jar application putting the .class files into a single file called my_utils ( .jar or .zip ?). Import the package from other projects using the import directive and storing the my_utils file in the project's library directory. Is this correct ?
    Many thanks in advance
    Marla.

    If you want to create a package and then put the package into a jar file, first compile into .class files (in appropriate package directories), then jar all of the .class files.
    Here's a link for a tutorial on packages. http://java.sun.com/docs/books/tutorial/java/interpack/packages.html
    Here's a link for a jar file tutorial. http://java.sun.com/docs/books/tutorial/jar/index.html
    You do not have put the .class files into a jar. Java packages are used for organizing classes, managing class name space, and controlling access to classes. Java jar files are a way to put multiple classes into a single file while compressing the content. Jar files can contain multiple packages and packages do not have to be inside of jar files.

  • Hi! I have a Creative suite Design Standard 9 Adobe program and I am attempting to make a wizzard form that can be made into an entry form for a competition. So I need to 1. Make the form into a question and answer form that Participants may fill out. 2.

    Hi! I have a Creative suite Design Standard 9 Adobe program and I am attempting to make a wizzard form that can be made into an entry form for a competition. So I need to 1. Make the form into a question and answer form that Participants may fill out. 2. make it possible for them to download it via a link on our website 3. make it possible for them to save the info they have written into the form and mail it to the mail we have supplied in the entry form and 4. make it possible for them to put in a jpg. as part of the entry for and lastly 5. make it possible for us to copy paste the document and use it on other platforms. How do I do this - is it at all possible with adobe?

    Those requirements are go way beyond what PDF forms can do and are meant for, some of them would require involving other programs or are mutually exclusive and contradictory. You are wasting your time even thinking about doing this as an "offline" PDF form. Simply sign up for an online forms/ survey service like FormsCentral or Surveymonkey.
    Mylenium

  • How to import BC4J package into JDEV project without server.xml file?

    Dear,
    I need to bring the seeded BC4J package into my JDEV OAF project. Usually to do that, once I am sure that all I need is accessible, I open the server.xml file for the BC4J that I need and I am all set - all the items from under that BC4J are brought in.
    How about if there is no server.xml file for that BC4J, for example, under oracle.apps.icx.por.req.webui, and I need to have a controller from under there in my project? Do I create this package (oracle.apps.icx.por.req.webui) manually? If I do that and then open the controller the controller is being brought into JDEV outside the package.
    Thank you.
    Anatoliy

    Sumit,
    Thank for quick response.
    Yes, I agree for the controller.
    But let's say I want to bring over some other xml staff, like some shared regions for example from under that webui. They are also brought outside the package. You have an idea?
    Regards,
    Anatoliy

  • I wanna ask you something. My bro has an iPhone 5s that disabled for 23 million because of the time changed to 1976. So, how to make it back into 2015, make it enabled without erase the data

    I  wanna Ask you something. My brother has an iPhone 5s that disabled for about 23 millions minutes  the time changed to 1976. So how to make it back into 2015 without waiting for 23 millions minutes later and enabled it without erasing any data? Please answer me ASAP because I really need it. Thank you for answer!

    Hello theshadowhunters,
    There is not much you can do to change the time back because he will not have access to change the time. The only option to get passed this is to restore the iPhone. Once the iPhone is restored and have a back up, you can put that back on once the restore is complete. For more information, take a look at the article below. 
    Forgot passcode for your iPhone, iPad, or iPod touch, or your device is disabled
    https://support.apple.com/en-us/HT204306
    Regards,
    -Norm G.  

  • My Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem

    my Creative Cloud subscription has expired, and I assigned the monthly payment, but I can not open any progam creative cloud, I need help how to solve this problem

    Carlos-
    Start by signing out and back in to see if it will see the subscription: 
    How to sign in and sign out of creative cloud (activate/deactivate)
    If the apps are installed fine and close after launch see this link:
    CC applications close immediately after launch
    If the problem is something different, please let us know the error you see or what is happening on the screen so we can advise  you on a solution
    Pattie

  • Hi, I have this green mark (with pointing arrow looks like a link) on some words show on my window screen when I open a web page, I wonder if it is a virus link or such. Need help how to get rid of it. Thanks

    Hi, I have this green mark (with pointing arrow looks like a link) on some words show on my window screen when I open a web page, I wonder if it is a virus link or such. Need help how to get rid of it. Here's the example:
    WING
    GAMES
    MAJORITY
    Thanks

    If the third link you posted (the link containing the word "majority") does not look like the following then you inadvertently installed adware.
    That particular page should resemble the following:
    The word "majority" in the third paragraph should not be a link and should not have the green icon associated with it.
    To learn how this may have occurred, and how to prevent it from occurring in the future, read How to install adware
    Most so-called "news" websites are nothing more than entertainment outlets that cater to prurient interests, and contain advertisements that leave the user about three clicks away from installing junk. If you decide to frequent those websites, Safari's "Reader" feature helps minimize that exposure.
    Try it:

  • Mail server not responding. Need help how to verify my account

    Mail server not responding. Need help how to verify my account

    There are instructions on this page for how to create a new account without giving credit card details (the instructions won't work with existing accounts) : http://support.apple.com/kb/HT2534
    Unless an account is created via those instructions then credit card details will need to be entered on it before the account can be used.

  • How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    How can I get a stripped screw out of the bottom of my iPhone?? I need help, How can I get a stripped screw out of the bottom of my iPhone?? I need help

    Try asking at ifixit.com. The iPhone is not considered user servicable. You're not going to get much help on an Apple sponsored forum.

Maybe you are looking for