Help dealing with jar file

hi all
i'm trying to deal with a jar file:
in myPackage.myClass i call:
Class.forName("org.hsqldb.jdbcDriver");i know that this file is contained into the file named "hsqldb.jar"
where shall i place this jar file in order to be found by myPackage.myClass without edit any system variable like class-path?
thanx a lot
sandro

For the jar, no, as jar's must be explicitly referenced on the classpath.
For the un-jar'd classes yes.
If they are extracted so their directory tree starts in the same place as the directory tree of your classes
e.g.
someDirectory
|
+-- yourComapay
|    |
|    +- yourApp
|        |
|        +- YourClasses
|
+-- com
      |
      +- importedPackage
          |
          +- ImportedClassesSo long as 'someDirectory' is on the classpath. It should run.

Similar Messages

  • Help needed with jar file

    hi, first of all sorry if my post is in wrong forum...but my application is done using swing so i am posting this here....and regarding my question...
    I have made an GUI using Java swings and my application is working fine. Now i want to make an executable jar file for my GUI. I have read some tutorilas on making jar files and this is what i have done...
    i have created a manifest file called mainClass.txt which has
    Main-Class: MainWindow ,where MainWindow is my main class name.
    Then i ran the jar utility with this command line:
    jar cmf mainClass.txt example.jar *.class
    With this line, I told jar to create a JAR file (option c) with modifications to the manifest file (option m) as specified within mainClass.txt, naming the JAR file (option f) as example.jar and including everything that matches the pattern *Class
    everything is file till now but my problem is ...I have some library files from JFreechart software included in my GUI to generate barcharts..How can i include these library files in my example.jar file..
    Kindly help me
    Thanks
    byee

    I had this problem too. I ran my program out of JCreator and it worked flawlessly. I jarred it up into and Executable Jar and I would get a runtime error explaning I have not included the correct libraries.
    What I did was look at the error, for example say it said something like:
    org.uhoh.PathSys ClassDefNotFound (or something similar to this)
    What I did was extract the library that contained that class file. Then in my project file where I kept my classes I made the folder org, then in org I made uhoh. Inside uhoh I copied over PathSys.class.
    I hope I addressed the problem you speak of. I am only a novice but this is how I figured it out. If anyone knows a better way let us know =D

  • Help me with jar file...

    I have created a jar file with the following cammand
    jar cvf XXX.jar com images
    where com is the folder which holding my all .class files and images is the folder which hold all my image files.
    but the prob is that when i run my jar file with the following command
    javaw XXX.jar com.Main
    Main is the main class
    i can't see nay images on my buttons in short i can't accress images files...

    satinderjit,
    Here is some code that you can use to grab an image (whether in a jar or not). Note though that your .class files will live in the com directory. So, in order for your images to load (with image path = "images/myImage.gif", you either have to move your image folder to your com folder or use the following string for your image path "../images/myImage.gif".
    /*=*******************************************************************
    * getImage(): grabs an image from the same location this file is at. *
    *     Works for when the images are in a jar or not.                 *
    public static Image getImage(String img) {
       /* Replace the 'YourClassName' with the name of your
          class.  Note that the .class file of the class
          that this method resides in must be placed
          relative to where the images are stored.  So
          if the images are in a folder called images,
          this .class file must be placed in its parent
          directory. */
       URL url = YourClassName.class.getResource(img);
       Image image = null;
       if (url == null) {
          System.err.println("Unable to load image: " + img);
       } else {
          image = Toolkit.getDefaultToolkit().getImage(url);
       return image;
    }//end getImage
    /* use the above method in the following manner
       (notice the forward slash).   The image path I
       provided should work with your current setup. */
    ImageIcon icon = new ImageIcon(getImage("../images/myImage.gif"));tajenkins

  • I am new with JAR files please help me

    Hi Dear All,
    I am new with JAR files, I know concept, but dont know how to careate JAR, and how do i use it?
    Please help me.
    Thanks

    This tutorial covers that:
    http://java.sun.com/docs/books/tutorial/deployment/jar/index.html

  • How to use javap with jar files ?

    how to use javap with jar files ?
    thanks

    As long as the jar is on the class path, your gold. So,
    javap -classpath myjar.jar mypackage.MyClass
    Chuck

  • Can Apple make an app or an update that makes you insert your password to turn your phone off? This can help deal with theft of iPhones because people take or find a iPhone, the first thing they do is turn the phone off.

    Can Apple make an app or an update that makes you insert your password to turn your phone off? This can help deal with theft of iPhones because people take or find a iPhone, the first thing they do is turn the phone off.

    They probably can do such s thing if they choose to do so.
    Let them know that you would like this:
    http://www.apple.com/feedback
    Not sure this is a very useful thing.  It would run down the battery.  All a thief has to do is remove them SIM and restore the iphone to stop it from being tracked.

  • How i can deal with oracle file by using php api

    how I can deal with oracle file by using php api ?

    What has this to do with Reflections and Reference Objects?

  • LTFS is slow when dealing with many files

    Working with LTFS on Windows 7 64, I find find that it slows down significantly when dealing with many files (>1500)
    From the behaviour, I suspect that it has to do with the number of file handles.
    Some LTFS vendors have a copy utility that deals very well with this situation.
    I could not find anything like that for HP.
    Does it exist? Is there an open source solution?
    Thank you,
    - Bartels

    Can someone from the Experts please respond?
    Your LTFS solution is in certain situations much slower than the competitors; the difference is a huge factor three..
    I would really like to know if there is a solution or not. Either way.
    - Bartels

  • URGENT Help for applet with JAR file in Netscape

    I am having Applet with few classes
    Html is in /www directory
    and all class files are in /www/javaclassfiles
    I jared all javaclassfiles with following command
    c:\www\javaclassfiles>jar -cvf sample.jar TaxPaymentAppletForm.class *.class
    where sample.jar is my jar file and TaxPaymentAppletForm.class is the main applet class file.
    THEN I DELETED ALL CLASS FILES & KEPT ONLY SAMPLE.JAR FILE ON SERVER
    My html code is like below:
    <APPLET CODE="TaxPaymentAppletForm" ARCHIVE="sample.jar" CODEBASE="JavaClassFiles" WIDTH=460 HEIGHT=400></APPLET>
    The things are running on IE properly, but not on Netscape. Netscape is giving following error :
    java.io.IOException: <null>
    at netscape.net.URLConnection.connect(Compiled Code)
    at netscape.net.URLConnection.getInputStream(Compiled Code)
    * at netscape.applet.AppletClassLoader.grabArchiveFile(Compiled Code)
    at netscape.applet.AppletClassLoader.openArchive(Compiled Code)
    at netscape.applet.AppletClassLoader.openArchive(Compiled Code)
    at netscape.applet.AppletClassLoader.<init>(Compiled Code)
    at netscape.applet.AppletClassLoader.getClassLoader(Compiled Code)
    at netscape.applet.DerivedAppletFrame$LoadAppletEvent.dispatch(Compiled Code)
    at java.awt.EventDispatchThread$EventPump.dispatchEvents(Compiled Code)
    at java.awt.EventDispatchThread.run(Compiled Code)
    at netscape.applet.DerivedAppletFrame$AppletEventDispatchThread.run(Compiled Code)
    # Unable to load archive http://nearbuy_server:90/iras/JavaClassFiles/sample.jar: java.io.IOException: <null>
    # Applet exception: class TaxPaymentAppletForm could not be loaded
    # Applet exception: class TaxPaymentAppletForm could not be loaded
    # Applet exception: class TaxPaymentAppletForm could not be loaded
    In netscape also it is sometimes running some times not, without any logical reson.
    Any help regarding this is appreciated
    manisha

    Following is the more detailed analysis when applet is running and when not
    On local server, it is running fine on both IE / Netscape
    When I transfered jar file to live server
    On IE it is running for the first time and then onwards not running, If I clear the catch then again applet is running.
    For second time it is giving following error :
    IOException Loading Archive: http://dev1.janusx-collections.com/iras/JavaClassFiles/AppletForm.jar
    java.io.IOException: dev1.janusx-collections.com:80//iras/JavaClassFiles/AppletForm.jar
    at com/ms/net/wininet/http/HttpInputStream.connect
    at com/ms/net/wininet/http/HttpInputStream.<init>
    at com/ms/net/wininet/http/HttpURLConnection.createInputStream
    at com/ms/net/wininet/WininetURLConnection.getInputStream
    at com/ms/vm/loader/JarArchiveSet.loadNextJar
    at com/ms/vm/loader/JarArchiveSet.getResourceBits
    at com/ms/vm/loader/JarArchiveSet.getClassData
    at com/ms/vm/loader/ResourceLoader.getClassData
    at com/ms/vm/loader/URLClassLoader.findClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    java.lang.ClassNotFoundException: TaxPaymentAppletForm
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/vm/loader/URLClassLoader.loadClass
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.processSentEvent
    at com/ms/applet/AppletPanel.run
    at java/lang/Thread.run
    ON Netscape it is NOT running at all on from live server and error is as given in above first post.
    manisha

  • Urgent help with jar file

    I'm writing a program in VB that calls on a JAR file. It has been working great for weeks. Last night, I moved the JAR file to a new location on my machine, and it suddenly stopped working at all.
    I know nothing about Java. Do I need to recompile the file? I tried moving the whole directory back to its original location but it didn't help.
    Thanks in advance.

    Dude I'm telling you straight up, the program has a bug. The evidence is in the error message. Maybe the bug was not manifested before, but it was there.
    Do you have access to the source? Do you know how to compile it? You should recompile it with the -g flag to include debug information. Then the error message will include a method name and line number for the offending portion of code. If you're not able to figure it out yourself, you could post that portion of code here for someone to comment on.

  • URLClassLoader - with JAR Files- - - Please Help

    Hi all,
    I have two seperate JAR files which contain same files but different progressive versions.JAR 1 is version V1 and JAR 2 is Version V1.1
    I have a program which loads classes from these two JARS and runs certain comparsions on them.CODE IS SHOWN and SO is ERROR.PLEASE HELP and ADVISE.Im on a UNix box using JDK 1.3.
    CODE:
    ====
    1.In my main i define the TWO JARS PATHS and the item to compare called ENTITYNAME as:
    String jarFile1 = "/xenv/GFINet_Java/6.2_Z1/1.3.X/gfinet_entities.jar";
    String jarFile2 = "/xenv/GFINet_Java/6.1_Y1/1.3.X/gfinet_entities.jar";
    String entityName = "gfinet.entities.GFIBasketEntity";
    2.Then i call the function
    EntityVersionComparator evc = new EntityVersionComparator();
    evc.test(jarFile1, jarFile2, entityName);
    3.Test function loads the JARS
    private void test(String jarFile1, String jarFile2, String entityName) throws Exception {
    URLClassLoader jar1 =
    (URLClassLoader)newClassLoader(jarFile1);
    URLClassLoader jar2 =
    (URLClassLoader)newClassLoader(jarFile2);
    4. Load that item ENTITYNAME FROM JAR.
    // load GFIBasketEntity from Jar1
    GFIBaseEntity ent1 =
         (GFIBaseEntity)loadClass(jar1, entityName).newInstance();
    PROBLEM ERRORS:
    ==============
    Exception in thread "main" java.net.MalformedURLException : no
    protocol :/xenv/GFINet_Java/sun4/6.2.Z2/Solaris8/3.3.2/1.3.X/lib/gfinet_entities.jar
    at java.net.URL.<init>(URL.java:473)
    at java.net.URL.<init>(URL.java:376)
    at java.net.URL.<init>(URL.java:330)
    at EntityVersionComparator.newClassLoader(EntityVersionComparator.java:143)
    at EntityVersionComparator.test(EntityVersionComparator.java:88)
    at EntityVersionComparator.main(EntityVersionComparator.java:74)
    WHATS GOING ON..Is there something wrong with the path?Pls advise
    jason

    I also in my CODE have:
    private ClassLoader newClassLoader(String path)
    throws MalformedURLException
    { URL url = new URL(path);
    return new URLClassLoader(new URL[]url);

  • Now what? Help with .jar files

    Hey. I just finished a program. I want to share it with my friends or anyone else. I can create a .jar file but I have no idea what to do next. Is there an easy way to "publish" your programs (like create a .exe file?). Any help or ideas would be appreciated. Thanks, Merlot14

    java -jar MyFile.jarwill work if you've set your manifest correctly. If you're distributing only to Windows users, you could include a shortcut, I believe. Similarly, for distribution to Linux/OS X users, you could include a shell script.

  • 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.

  • Help me this error :"uncaught error fetching image" with Jar file

    Hi all.
    I have a program written with Swing. This program has one button and fetch Image into this button. Image is in Images directory .When I run this program by IDE, It's OK. However, when I compress classes of this program into Jar file and run, it can not recognize the path to Image. And it leads to this error:
    "uncaught error fetching image"
    I have tried to look for a lot of information relating to this problem on the internet but nothing is possible.
    Please help me. Thank you.
    And my program
    http://www.mediafire.com/?j0yzun4d0mx

    When you JAR it's different. Try something like this:
    BufferedReader br=new BufferedReader(new InputStreamReader(getClass().getResourceAsStream(listname)));
    you don't hae to do the BufferedReader, but the getClass().getResource... is what you need.

  • Problem with jar file please help!!

    Hi everybody
    I make a jar file using Jbuilder;my application interact with oracle and when i try to run it ,I get the following message:
    "no driver was found "
    however i add the oracle driver in my jar file as a library dependencies.
    could some one help

    I don't know whether this will help you or not.
    You have mentioned that drivers are added into jar file which you have created. Similar situation I faced. In my case I added classes12.zip for ORACLE thin drivers. For this to work I had to set classpath for this zip file. Once I set the classpath for this zip file my application started working fine.
    So if you are using any zip or jar file for your driver you will have to define it in your classpath.
    Mushy

Maybe you are looking for

  • Pdf extension changes to .dat when send a file via e-mail from adobe acrobat 9

    to convert a file from microsoft word 2007 to PDF and send as an attachment via e-mail from adobe 9, the file is received with the extension changed to. dat, so recipients can not open it. Can anyone help me with this.

  • Amount of primary freight

    Hi Guys, Could you please suggest me for below report. A report that will provide the amount of primary freight we spent in 2007. The freight costs need to be reported in two ways: Vendor to Distributor - Distributor to Distributor Thnaks tata

  • Error when creating a FDM application on SQL Server 2005

    Hi, we are getting this error when creating a FDM application on SQL Server 2005 Error: EPMCSS-07003: Failed to validate identity. Invalid identity . Check identity.[SET_ROLES_LIST] We are using Windows System Integration although we have also tested

  • Sync config between active and standby CSM

    Is there a way to sync config between active and standby CSMs? Just as one that in CSS. How about two SSL Service module in two different 6500 chassis? Thanks.

  • Sound - No microphone gain ?

    MSI P35 Neo 2 FS Intel E8400 processor 2 x 1 Gig Corsair Ram 8800 GT Graphics card 550 watt Trust PSU Window Xp Home Edition. Realtek ALC 888/888T audio. When I try and connect to SKYPE the recipient informs me that my microphone volume is too low, a