Need help about jar file again!!

I want to make some of my package used as library. And also put my application into executable jar file. I edited following codes:
uner path: D:\dd\b\b1
package b.b1;
public class Son
     int x = 10;
     public Son(){
     public int getX(){
          return x;
under path D:\b\b2
package b.b2;
import b.b1.Son;
public class Father
     public Father(){
     public static void main(String[] args)
          Son son = new Son();
          System.out.println("Hello World!"+son.getX());
Then I used jar tool make two jar files and also make one of then has specified main class Manifest.mf.
Here is my steps:
D:\bb>edit kk.txt
D:\bb>jar cmf kk.txt father.jar .\b\b2
D:\bb>jar cf son.jar .\b\b1
D:\bb>java -jar -classpath .;son.jar father.jar
Exception in thread "main" java.lang.NoClassDefFoundError: b/b1/Son
at b.b2.Father.main(Father.java:13)
I really do not know what's going on?
Interesting thing is I can get this result:
D:\bb>java -classpath .;son.jar b.b2.Father
Hello World!10
And if the father.jar does not depend on son.jar,
it is also works.
Thanks in advance.

I believe when you run with the -jar option, the classpath setting is ignore and you have to specify classpath in the manifest file.
From JDK Doc:
Class-Path :
The value of this attribute specifies the relative URLs of the extensions or libraries that this application or extension needs. URLs are separated by one or more spaces. The application or extension class loader uses the value of this attribute to construct its internal search path.
Sounds like you can specify a different path than the current directory, but you have to know beforehand what that path is.

Similar Messages

  • Need help about jar....

    hello everybody
    i have created a database application using mysql and java application run very fine with out jar but after making jar file application can not connect to database and thorws nullpointer exception here is it
    plz help me what i have to or any thing to do in manifest file......or any setting class path....

    You should always copy and paste the full, exact error message when asking for help.
    The error message tells you which line of code is throwing the null pointer. Investigate that line - the line contains some reference variable whose value is null. Then you need to figure out why it is null and fix it.

  • Need help with jar files

    I have made an application that uses the javax.comm library for serial port drivers. It works perfectely but when I put all the .class in a .jar and start the application it starts properly with no errors but it doesn't see the com's of the computer.
    I would apreciate if you could help me out
    greetings
    paul

    You have to modify the source code of the javax.comm class files you are using.. the line contains "package javax.comm;" should be deleted. And then compile those modified files and put the compiled files to your jar file. Or you can create a folder "javax" and subfolder "comm" in that folder and put those original .class files into "javax/comm". After that, put that "javax" folder into your jar file.

  • Need Help for Jar Files Operations!

    Hi,
    I am trying to extract files from jar file using the java code. Does any one knows how can one do this using java code.
    Or
    is there any facility that I can use the unjar command inside the java code to extract it. I wonder about this!
    Or
    does java povide Java APIs provides facility for this. I have gone thourgh java.util.jar package but am not to get how can this be used for the above purpose?
    Thanks.
    Huzefa

    The following will display each file in the zip/jar file to the screen.
    ZipInputStream zin = new ZipInputStream( new FileInputStream( "z:\\myzip.zip" ) );
    ZipEntry entry;
    while( (entry = zin.getNextEntry() ) != null ) {
         System.out.println( "Entry: " + entry.toString() );
         byte[] buf = new byte[ (int)entry.getSize() ];
         zin.read( buf, 0, (int)entry.getSize() );
         System.out.write( buf, 0, (int)entry.getSize() );
    Jar* extends Zip*.

  • Need help with Jar file

    I am writing an Application in Java using swing and all that good stuff but I am currently ready to do some beta testing to find any other errors.
    The problems is I want it to be easy to use so I was just going to throw the classes ina jar file so they could just run the jar files.
    For some reason I keep getting a cannot find main class error??
    Here is the manifest file for the Jar file
    Manifest-Version: 1.0
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    Main-Class: VRPServer.class
    VRPServer is the class that has the main in it.
    if I go to the command line and run I get
    E:\JAVA\VRP\Server>java -jar VRPServer.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: VRPServer/class
    if I double click the jar I get a pop-up saying "Could not find the main class, program will exit."
    I really don't understand Jar files all that well, I went through the tutorials but still can't see why this isn't working. Any help is appreciated. :)

    I think your problem is that you shouldn't add the '.class' to the name of your main class in your manifest; it should simply be the fully-qualified name of the class, for example:
    Manifest-Version: 1.0
    Created-By: 1.4.0_01 (Sun Microsystems Inc.)
    Main-Class: mypackage1.mypacage2.MyClassHope this is all it takes.
    Shaun

  • Need help about the SHA Message Digest ? & what is use of Message Diagest ?

    need help about the SHA Message Digest ? & what is use of Message Diagest ?
    1>i have one program of making message digest
    2>which requires two files name
    3>one for input like txt
    4> second is out put file of message digest
    can any one tell what is the use of second generated file .

    MessageDigest md = MessageDigest.getInstance("SHA");
    FileInputStream fis = new FileInputStream(args[0]);
    byte[] b = new byte[1024];
    int readed = -1;
    while((readed = fis.read(b)) > 0)
         md.update(b, 0, readed);
    fis.close();
    FileOutputStream fos = new FileOutputStream(args[1]);
    byte[] d = md.digest();
    StringBuffer sb = new StringBuffer();
    for(int i = 0; i < d.length; i++) {
         String str = Integer.toHexString(d[i] & 0xff);
         sb.append(str.length() < 2 ? "0" + str : str);
    fos.write(sb.toString().getBytes());
    fos.close();

  • Need help about 1015

    need help about 1015 it says connect iphone to itunes on screen i did it but it doesnt work and says unexpected 1015

    Try restoring it: Make sure you are following the instructions in this procedure to the letter.  Here they are, with emphasis on some easily overlooked requirements:
    Disconnect the USB cable from the iPhone, but leave the other end of the cable connected to your computer's USB port.
    Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.If you cannot turn off the device using the slider, press and hold the Sleep/Wake and Home buttons at the same time. When the device turns off, release only the Sleep/Wake button.
    Continue pressing and holding the Home button while you reconnect the USB cable to the device. The device should turn on.
    Note: If you see the "low battery" screen, let the device charge for at least ten minutes to ensure that the battery has some charge, and then start with step 2 again.
    Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears (iTunes icon and USB connector) release the Home button.
    If necessary, open iTunes. You should see the "recovery mode" alert ("iTunes has detected a phone in recovery mode").
    Use iTunes to restore the device.
    If you do not see the "Connect to iTunes" screen, try these steps again.
    If you see the "Connect to iTunes" screen but the device does not appear in iTunes, see this article and its related links.
    If you have backed up the iPhone in the past, select the device in iTunes and choose "restore from backup".

  • Need to download JAR files from more than ONE HTTP-server ?

    Hello,
    We have a need to download JAR files for an application, from more than ONE HTTP-server, i.e. any specified HTTP-server in an extremely secure network.
    Does a solution exist for this requirement ? Is it possible to design a solution our selfes for this problem ?
    Best Regards
    Peter

    We have a need to download JAR files for an
    application, from more than ONE
    HTTP-server, That can be done using the extension element
    from within the resources element of the main JNLP.
    http://java.sun.com/j2se/1.5.0/docs/guide/javaws/developersguide/syntax.html#resources
    The extension element should refer to another JNLP
    (on the other site) that refers to the Jars. The jar files
    in any such (foreign) JNLP need to be signed, and the
    JNLP files should declare itself as a <component-desc>.
    For any level of detail on using extensions/components,
    download the spec. mentioned in the second paragraph
    of that section linked above. Unfortunately I can find no
    web browsable form of the information.
    Here is an example though..
    http://www.javasaver.com/testjs/jws/04/glclock.jnlp
    This (sandboxed) screenaver demo comes off my
    javasaver site. It refers to the JOGL API via an
    extension element in the JNLP, that points directly
    to the JOGL site. You might notice the security
    warning that is produced mentions..
    Name:      JOGL
    Publisher: sun microsystems, inc
    Source:    https://jogl.dev.java.net
    ..i.e. any specified HTTP-server in an
    extremely secure network. I do not know about an extremely secure network,
    but if it is OK to launch a normal JNLP for an
    application with a 'main()' from the server, I guess
    it should be OK to launch extensions off it - you
    might need to set up some tests.

  • Help using jar file!

    Help using jar file!
    Hello
    I have created a jar file by using
    jar cvmf Manifest.txt myjar.jar 1.class Mydirectory
    In 1.java file :I have used
    JEditorPane editor;
    editor.setPage(getClass().getResource("/Mydirectory/default.htm"));
    If I am only giving myjar.jar file to the client without Mydirectory then also it is working fine by showing default.htm in JeditorPane.
    But my problem is I want to use
    Runtime.getRuntime().exec("cmd /c start IEXPLORE"+targetstr) ;
    targetstr will be the filename with path of the default.htm
    If I am giving myjar.jar file with Mydirectory to the client it is working but I don't want to give Mydirectory to the client .
    What should I do?
    Is there any solution for this?
    Using another jar file which will include mydirectory can solve this problem?
    Is there any othe concept in java so that I wll be able to hide Mydirectory from client?
    Please help.

    It seems like you could extract the .htm file from the jar, either with Runtime.exec or using the Jar API classes.

  • Need help about Hidden Markov Model model

    I want to make classification for EEG signal using Hidden Markov Model
    algorithm based on neural network.
    plz need help about how to implement this algorithm using LABVIEW.
    if not I want another thing to make classification.
    any one know information about this topic, send me a reply
    thanks

    Have you derrived the HMM that you want to implement?
    If so, post the algorithm and we can provide comments on how to implement it using LabVIEW.
    Message Edited by Ray.R on 04-12-2010 12:54 PM

  • An error occured while trying to copy the needed DB driver jar files

    When I try to run my web app, I see this error in the Output window.
    Creator will also put up a window essentially saying that I don't have a particular
    data source. But I do have that very data source there.
    The error seems to be pointing to this line in my build-impl.xml file
    <nbdeploy debugmode="false" clientUrlPart="${client.urlPart}" forceRedeploy="${forceRedeploy}"/>

    I'm using postgresql-8.1-404.jdbc3.jar
    I started this project with Creator2, so I don't know if the nbproject files
    are out of date or anything.
    Here's the output text:
    init:
    deps-module-jar:
    deps-ear-jar:
    deps-jar:
    Copying 1 file to /home/tc/dev/oms/src
    library-inclusion-in-archive:
    library-inclusion-in-manifest:
    Copying 1 file to /home/tc/dev/oms/build/web/WEB-INF/classes
    load-project-properties:
    installGraphics:
    installLayouts:
    compile:
    compile-jsps:
    pluto-hack-web-xml-run:
    portlet-container-deploy:
    jsCreatorDist:
    run-deploy:
    An error occured while trying to copy the needed DB driver jar files.
    Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    Exception=Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:198)
    at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:75)
    at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:275)
    at org.apache.tools.ant.Task.perform(Task.java:364)
    at org.apache.tools.ant.Target.execute(Target.java:341)
    at org.apache.tools.ant.Target.performTasks(Target.java:369)
    at org.apache.tools.ant.Project.executeTarget(Project.java:1214)
    at org.apache.tools.ant.Project.executeTargets(Project.java:1062)
    at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:234)
    at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:242)
    at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:125)
    Caused by: An error occured while trying to copy the needed DB driver jar files.
    at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:139)
    ... 10 more
    /home/tc/dev/oms/nbproject/build-impl.xml:799: Deployment error: An error occured while trying to copy the needed DB driver jar files.. See the server log file for details.
    BUILD FAILED (total time: 7 minutes 21 seconds)

  • Need help about ref cursor using like table

    Hi Guys...
    I am devloping package function And i need help about cursor
    One of my function return sys_refcursor. And the return cursor need to be
    join another table in database . I don't have to fetch all rows in cursor
    All i need to join ref cursor and another table in sql clause
    like below
    select a.aa , b.cc form ( ref_cursor ) A, table B
    where A.dd = B.dd
    I appeciate it in advance

    My understanding is that you have a function that returns a refcursor and is called by a java app.
    Because this is a commonly used bit of code, you also want to reuse this cursor in other bits of sql and so you want to include it like table in a bit of sql and join that refcursor to other tables.
    It's not as easy as you might hope but you can probably achieve this with pipelined functions.
    Is it a direction that code should be going down? yes, eventually. I like the idea of pulling commonly used bits of code into a SQL statement especially into the WITH section, provided it could be used efficiently by the CBO.
    Is it worth the effort given what you have to do currently to implement it? possibly not.
    what else could you do? construct the sql statement independently of the thing that used it and reuse that sql statement rather than the refcursor it returns?
    Message was edited by:
    dombrooks

  • Need help about boot SUNFIRE V120

    Hi all....
    I need help about how to change boot from boot net to boot disk....
    after i installed sun solaris 10 at my sunfire v120, then reboot the machine ... this sunfire still boot from net not from disk...
    can i change it?
    please i really need help ....
    thanks

    If its booted, try "eeprom boot-device=disk"
    If your at the OBP, "setenv boot-device disk".
    If that doesnt work check the value of "diag-switch?".
    It could be booting off the the diag-device instead

  • Need Help about 3D and revolving in illustrator

    I really need help about 3D, Please tell me that How i create 3D in illustrator
    i want to revolve text or shape around any object like this, any plugin? or other software required for this?
    if somebody know this it will be really help full
       http://rcgrafix.fizwig.com/1452732-large.jpg    
       http://rcgrafix.fizwig.com/1384370-large.jpg
       http://rcgrafix.fizwig.com/1062180-large.jpg
    Thanks
    Arsi

    if links are not working try Copy and paste it in to your browser address bar
    thank you

  • Hi, Need help about ios7 upgrade, after this upgrade I cannot watch youtube or any video with my Ipad,

    Hi, Need help about ios7 upgrade, after this upgrade I cannot watch youtube or any video with Ipad, and Iphone as well
    I think my wireless rooter's setting has some problem but cannot found anything to solve,
    I can watch if there is another wireless network , I tried this option in another place who has wireless network and I can watch.
    Do you have any idea to do these setting , I dont have any problem when Ipad has 6.1.3 IOS,
    need help
    thanks

    Thanks
    I will and share the result.

Maybe you are looking for

  • A rant about C with a question at the end. :P

    C is okay. It's just really hard to understand. So this is my rant about it. It starts out by listing where I've been in terms of programming and then lists my difficulties with C itself. I discovered C many years ago. I'm not too sure how. All I kno

  • Add a new folder to bookmarks?

    In Safari the prompt add a new folder comes up, but in Firefox I cannot find that prompt anywhere. When bookmarks is open, the View/Sidebar is not available.

  • Logic 7.1 compatability with Pro Tools Mix?

    Hi, Can I import audio or open a file from a Pro Tools Mix session, and if so, how? I'm sort of confused as I thought that Logic could open and save as SDII. Am I wrong here? Thanks, Jim

  • Unable to download app

    I Am able to go to adoberevel.com and sign in fine. But when I've tried to download the app update on both my iPhone and iPad I get the following error box: Unable to Download App Adobe Revel- Cloud access for all your photos and videos could not be

  • Moving "Faces" only data into Aperture from iPhoto

    Just starting out with Aperture 3. Don't want to migrate my iPhoto library to my new Aperture library and clutter everything up. BUT, I do want to have it all the Faces data imported so that any new photos I import will be tagged appropriately. Is th