Problem in include library files into my jar file

i am new to this jar archiving...I have created a GUI with java swings..and i also use mysql driver to connect my database now i want to make an executable jar file for my GUI..with coonector i have done the following
I have compiled my program and placed all the .java and .class files in
c:\ java\ bin\ jarexample
next i created a manifest file called mainClass.txt which contains
Main-Class: AppletMain (where AppletMain is my mainclass).. I placed this txt file also in c:\ java\ bin\ jarexample
i m also set Class-path in manifest file Class-Path: mysql-connector-java-3.1.10-bin.jar
next i ran jar cmf mainClass.txt example.jar *.class mysql-connector-java-3.1.10-bin
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 and mysql connector
now my problem is ...my MYSQL connection need some Library files from a package called org and class Driver.class to generate connection I include this library files also in my example.jar....
But when i execute this jar file using :java -jar example.jar
this is executed BCOZ tha example.jar file use mysql-connector-java-3.1.10-bin.jar file from system.
If i m this mysql-connector-java-3.1.10-bin.jar file from system from system then it is not run.
Can anyone please tell me how can i include this library file to my jar file( ie example.jar)
Thankyou

Double post. Please post replies on the other thread.
http://forum.java.sun.com/thread.jspa?threadID=656781&tstart=0

Similar Messages

  • How can  I include my database file into my jar file?

    Hi,
    I am doing several tests for the jar command....
    I tried to put the database file into my jar file, but when the program run, it just couldn't find the database file, so how may I include the database file into the jar file? Not only that, it also can't find the policy file etc.

    sorry, I think I found the solution, I should have had read the API more carefully.

  • Beginner: Can't convert a hello.class file into a jar file: HELP PLEASE!!!

    Hi, I created a hello.java file, converted into a hello.class file by using the java 2SDk compiler. The problem is that the hello.class file is in a directory I created: C:\JavaBuilder\hello.class
    I have a problem converting the hello class file into a jar file. I don't know which approach to take. I've looked at tutorials...but I keep getting more confused each time I view the tutorials on creating jar files. Please can someone help..by taking me through a step by step process. Please be explicit and do not leave or assume that I know any details because I'm a new born beginner. Thank you very much, I seriously appreciate it.

    Hi i did as you suggested, only with these exceptions:
    jar -cvf hello.jar C:\JavaBuilder\hello.class
    I did this and got the message: "adding : C:\JavaBuilder\hello.class (in=1150) (out=708) (deflated=38%)"
    The problem is that when I tried to execute the jar file...by typing: " java -jar hello.jar" I received the error message: "Failed to load Main-Class Manifest attribute from hello.jar" Is there any way to correct this problem? please help, thank you.

  • Beginner: Can't convert a hello.class file into a jar file. Please Help!!!

    Hi, I created a hello.java file, converted into a hello.class file by using the java 2SDk compiler. The problem is that the hello.class file is in a directory I created: C:\JavaBuilder\hello.class
    I have a problem converting the hello class file into a jar file. I don't know which approach to take. I've looked at tutorials...but I keep getting more confused each time I view the tutorials on creating jar files. Please can someone help..by taking me through a step by step process. Please be explicit and do not leave or assume that I know any details because I'm a new born beginner. Thank you very much, I seriously appreciate it.

    Hi!
    first of all, you should use an upper-case character for the first letter of your classes...
    To answer your question :
    1) you must create a directory named "meta-inf" in your directory "C:\JavaBuilder"
    2) then,you must create a file named "manifest.mf" in this directory
    it's like a property file and it must contain this :
    Main-Class: hello
    (don't forget to type <enter> after "hello")
    3) in the directory "C:\JavaBuilder", you can enter the following command :
    "jar cvfM hello.jar meta-inf\manifest.mf hello.class"
    (check jar.exe is in your path)
    4) you can run your jar by the command :
    "java -jar hello.jar"

  • Conversion of a .class file into a .jar file

    Conversion of a .class file into a .jar file
    How Will I convert a .class file into a .jar file.
    Pls answer ASAP.

    You don't.
    You add a .class file into a .jar file. You don't convert anything.
    Read the help page for jar for details.

  • Including a rms file into a *.jar file

    Hi,
    I would like to know if it's possible to include a rms (RecordStore) into a jar file off a Midlet suite. I don't want to create the RecordStore everytime i need to install my application. I tryed to copy rms.db to the instalation dir and it worked but i have tools that allow me to do that. My possible clients don't, and i wish to include the rms in the instalation to jar in order to be transparent to them. Adding file to *.jar doesn't work, because the file remains inside the *.jar and isn't installed in the application dir.
    I appreciate some help
    Thank u and by the way
    MERRY CHRISTMAS

    Hi
    I'm not aware of any technique for directly loading an RMS via the JAR.
    Instead, have you considered using a resource file and initializing the RMS from that? Or initializing from a network connection? You could also use the optional properties in the JAD for key=value pairs.
    We have used all 3 techniques - including using the resource file as a default dataset and then relegating the RMS to holding any dataset updates.
    Happy New Year

  • How to include third party .jar files into my jar file

    Hi,
    how do i include a open source third party jar file into an executable jar?
    i have a class called BlogBox.java and it uses org.apache.commons.net.ftp.FTPClient, i want to create an executable file, where do i put the .jar file containing FTPClient aka Apache Commons Net?
    currently i'm getting the following error from when executing my BlogBox.jar
    C:\MyJava\BlogBox>java -jar BlogBox.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
    at blogbox.BlogBox.<init>(BlogBox.java:27)
    at blogbox.BlogBox.main(BlogBox.java:103)
    Any suggestions? i have searched google and this forum but could not find the solution to my problem, thanks
    [edited msg] do i need to add the classpath at execution or something of the apache commons net library?
    Message was edited by:
    gekkokid

    When you use an executable jar the normal class path
    is ignored, but you can put a classpath inside the
    jar. The usual trick is to place the library jar
    files in a directory inside the application directory
    and direct the manifest file to it. The manifest file
    live in the jar inside the META-INF directory and
    it's called manifest.mf
    The two heavilly used entries are Main-class: and
    Class-path: lines. Class-path just has a
    comma-separated list of library paths.
    The jar utility has a special option to load it up.Thanks :) I created a "/lib" directory, placed in the packages in there and redirected the Class-Path: lib/commons-net-1.4.1.jar
    and it works,
    thank you everyone :)

  • Updating a specific file into a .jar file

    Hi,
    I have got a .jar file, if I want to update the specific file org/abc/try.class, with a new try.class, what command should I use?
    thanks a lot.

    Something like that, but remember you have to rebuild the entire jar file from scratch. You can't just update one file in it.

  • How to load xsl-files out of jar-files

    Hi,
    I have included some xsl-files into a jar-file. I can access this files with the following code-snipped if the jar-file is local on my harddisk:
    ClassLoader.getSystemClassLoader().getResource("pcodeliste.xsl").openStream()
    But the problem is that I use this jar-file as a part of a j2ee-application (it's a ear-file). After deploying this ear-file to my application-server (oc4j) I get a null-pointer exception if I call the xsl-file with the code above.
    Can anybody help me how to change this code or how to change the j2ee-application to have access to this files??
    Thank you very much
    Tobias

    Hi Rykk!
    Thanks for the answer, but it does not work since the jar, containing my file is inside an ear.
    Greets,
    Jay

  • Problem with JSP using bean packaged in jar file

    Hi,
              I am trying to use a java bean in a jsp file. The java bean is packaged
              into a jar file. I am getting class not found compilation error. If the
              bean remains to be a seperated class file, everything work well.
              Does anyone know how I can use bean in a jar file within jsp , i.e. to
              allow the bean to be found during compilation ?
              Thanks,
              Terence.
              [email protected]
              

    Jacek,
              Thanks for replying.
              My JSP's are just files in my document root . However, I found a solution to
              my
              problem. That is to have the jar file defined in my weblogic.class.path. I may
              have missed some files in my original jar file which causes my problem.
              Mayby I should package everything into a web application for deployment. That
              will be my next step.
              Thanks anyway.
              Terence.
              Jacek Laskowski wrote:
              > Terence Lai wrote:
              > >
              > > Hi,
              > >
              > > I am trying to use a java bean in a jsp file. The java bean is packaged
              > > into a jar file. I am getting class not found compilation error. If the
              > > bean remains to be a seperated class file, everything work well.
              >
              > How do you use the JSP file ? Is it a part of web application ? If so,
              > the bean jar package should be located in WEB-INF/lib directory. It's
              > also recommended to put the bean class into a package, so it's not in
              > 'unnamed' package, and <jsp:useBean> can find it.
              >
              > >
              > > Does anyone know how I can use bean in a jar file within jsp , i.e. to
              > > allow the bean to be found during compilation ?
              >
              > see above.
              >
              > > Terence.
              >
              > Jacek Laskowski
              > HP Consulting
              

  • How to package other jar files into one jar?

    How to package other jar files into one jar? How can i get the class in the inner jar file?

    Generally not a good idea. The Java runtime won't be able to load classes from those "inner" jars, you'd have to write your own classloader to do that. It's not a brilliant idea, generally, anyway, since the point of having lots of jars is to keep your application modular. Bundling them all together like that means you have to re-deploy the whole thing to fix, for instance, one small bug in one small library
    If you really want to do this, there's an Eclipse plugin called FatJar, but I urge you to consider whether you really want to do it first.

  • How do you convert a jar file into a java file,  ?

    how do you convert a jar file into a java file ?
    I am new to Java ,but have a little experience in C++ and Visual Basic.
    I want to edit and maybe create my own mobile games that are written or converted into jar files.
    At the moment I am using Java NetBeans , and Easy Java( the java pad).
    However the only solution I tried was to open the JAR file in winrar and see that its made up of png picture files,
    midi music files and class files. Unfortunately when I uncompressed the JAR file , there was NO java file to be seen and the JAVA editors Do not show the class file like a Java file. So why is there no extension Java file in the mobile JAR game ?

    801283 wrote:
    how do you convert a jar file into a java file ?You generally don't. There exist decompilers, but if you're meant to have the source, you should either have it because you are the author, or you should be able to get it from the author.
    I am new to Java ,but have a little experience in C++ and Visual Basic.Does that experience include turning .exe files into C++ code? Because that's the equivalent of what you're asking
    I want to edit and maybe create my own mobile games that are written or converted into jar files.Eh?
    Are you saying you want to take existing games and modify them? If the creators allow you to modify their source, then they'll provide you with that source (the .java files). If you're allowed to add things but not modify, you don't need .java files. Just documentation, which, again, the creators should be providing.
    Or are you saying you want to create your own games and distribute them in jar files? If so, there's no need to turn jars into .java.
    However the only solution I tried was to open the JAR file in winrar and see that its made up of png picture files,
    midi music files and class files. Unfortunately when I uncompressed the JAR file , there was NO java file to be seen and the JAVA editors Do not show the class file like a Java file. So why is there no extension Java file in the mobile JAR game ?Why would you expect there to be one?

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

  • Conversion of a .jar OR a .class file into a .exe  file

    Can anyone tell me as how to convert a .jar OR a .class file into a .exe file
    I need to know as soon as possible.

    Okay I will tell you the steps:
    Look in the top right hand corner of the page.
    There should be a box with a red title line. Inside the
    title should be the letters 'S E A R C and H'.
    In the white part of th box should be a smaller line, in which you can type.
    type in "conversion .jar .class .exe" or some similar string.
    Then click on the button next to the text box.
    Read the page of results you get.
    Click on the first link and read what is said on the connecting page.
    If that doesn't help, use your browser's back button and click on the next link, and repeat util your question is answered.

  • Including a .jad and a .jar file in presentations

    Hi:
    I did an application using the last version of the Sun Java Wirelless Toolkit 2.5. And now I have a .jad file and a .jar file. I need to include both in a power point presentation to be able to show the application. I dont want to do a link because I'm not gonna use my computer to do the presentation. Do I need to do something special in the deployment step to be able to do this ?
    I have tried to include the program this;
    Insert --> Object
    But it doesn't work.

    Hey listen what you want to do is possible but not in the way you want to do...
    if you want to demonstrate the functionality of your application or how it works then you can use use
    any screen recording software such as: Screen Recorder Gold, Qarbon's Viewlet Builder or ViewletCam
    such software help you to record the activity of screen then you can export the recorded screen shots to multiple formats and include them to your PP presentation...

Maybe you are looking for