How to Include libraries (Jar's/Packages/ClassNotFoundException/Classpath)

Ive spent hours looking for a solution, So maby i making a simple human error which i cant find.
Im unfamiliar with using packages.
I have created a program that use the JDBC libary. However i need to distribute this program and keep getting a ClassNotFoundException which is throw by:
String s = "com.mysql.jdbc.Driver";
Class.forName(s);I would like to have the "mysql-connector-java-bin.jar" file inside my main jar file However I think this may be very complex so i assume it would be easier to have it in the same directory as the main jar file.
I create my main jar file with:
jar cmf mainClass.txt Main.jar *.class mysql-connector-java-bin.jarI also jarsigner but i wouldn't expect this to case this problem.
mainClass.txt
Main-Class: MyClassFile
Class-Path: mysql-connector-java-bin.jar
Sealed: trueAny ideas what im doing wrong? or How i could solve this problem?
Do i need to write a program which installs the JDBC on their system?
Is there an easy solution?
Any advice would be greatly appriacted.
Thanks,

ty for the reply
I now create my jar file with:
jar cmf mainClass.txt Main.jar *.classand the "mysql-connector-java-bin.jar" is still in same directory as my main.jar file
Ive also replaced the "mysql-connector-java-bin.jar" to make sure it hasnt been corrupted somehow.
However i still get the same error.
the stackTrace is:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClassInternal(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at SQLConnection.<init>(SQLConnection.java:18)SQLConnection a class i have created.and the lines 17 and 18 are posted in my first post.
Anyideas?

Similar Messages

  • ANT how to include NetBeans Jar  files in my script of ANT ??

    ANT how to include NetBeans Jar files in my script of ANT ??

    I mean the library say swing layout ...
    which is SwingLayOuts1.0.jar ...
    in side this there is folder org.jDesktop....
    I want this folder in my jar file ...
    also ....
    My question ... i know the path of the jar file of NetBeans .... i can copy that ...dirctly ... but if m using Netbeans editor ... can i give NetBeans class to my jar command for ANT...........

  • How to include other jars when using servicegen

    I have been trying to use servicegen with regular java classes but I can't figure
    out how to include other jars that the webservice class uses?
    How is this supposed to be done?

    SQL> set null <<NULL>>
    SQL> select distinct comm from emp
      2  /
        COMM
           0
         300
         500
        1400
    <<NULL>>
    5 rijen zijn geselecteerd.So I probably don't understand the question. Could you post a small test case showing the behaviour you described?
    Regards,
    Rob.

  • How to include external jars - URGENT...

    Hi:
    I am using Eclipse for development.
    My application uses some external jars.
    This step is simple in Eclipse, one simply indicates where the jars are to the IDE.
    However, when I make an executable JAR file from my project, those external JARs are not included.
    So when I run my program, everything is fine until the parts that uses the external JARs.
    Does anyone know how to include them outside of Eclipse platform?
    I am going to see my client in an hour and of course I can't bring my source and install an Eclipse at my client's computer to show them my demo...
    please help... thanx...

    You add those external jars to the classpath or the jars classpath if you're running the program from a jar. Or put the external jar to JAVA_HOME\lib\ext (IIRC)

  • How to include ojdbc.jar with applet in apex

    Hi,
    I am integrating applet with apex. I need to use ojdbc.jar to connect to Database. How can i include this jar. I tried uploading it as a static file. But i am not sure how to embed it with applet code in region source of a page. I am using following code to embed the applet.
    <applet code="TestApplet.class" archive="#APP_IMAGES#Test.jar" width="500" height="500">
    </applet>
    Please suggest how to include the ojdbc.jar.
    Regards,
    Shweta

    Thank you all for help, from your posts I was able to get the datepicker working with a different version of jQuery (but not jQueryUI) included on the page. There are two methods:
    1. Include the new library before #HEAD# and change the reference to a different variable, for example:
    <script src="jquery-1.6.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      var jq164 = jQuery;
    </script>
    #HEAD#2. Include the new library after #HEAD# and enable noConflict() mode, for example:
    #HEAD#
    <script src="jquery-1.6.4.min.js" type="text/javascript"></script>
    <script type="text/javascript">
      var jq164 = jQuery.noConflict(true);
    </script>In both examples above, $, jQuery and apex.jQuery point to apex jQuery, while jq164 points to the new one.
    However, I couldn't manage to include a newer version of jQueryUI. I only found a page ([url http://stackoverflow.com/questions/6358961/using-multiple-jquery-ui-versions]http://stackoverflow.com/questions/6358961/using-multiple-jquery-ui-versions) that says you have to specify a different context for each version of jQueryUI included on the same page. I haven't yet had time to look at this, so if anyone already knows how to do it, it would be really nice to share it with us.
    Regards,
    Jure

  • How to include others jar in my project use netbean

    Hi,
    Here i'm build my project in netbean, in compile source i add jdom.jar. Afer compile, run jar from terminal. But, application can't use and error :
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/jpos/
    iso/ISOPackager
    Now, i ask : How to include others lib or jar in my project use netbean
    Rgds,
    Wira S

    Dear All,
    The code In manifest.mf, like :
    Manifest-Version: 1.0
    X-COMMENT: Main-Class will be added automatically by build
    Main-Class: root/Phase3/TesterPhase3/IsolibTester/src/isolibtester/DynamicTreeTester
    Class-Path: root/Phase3/TesterPhase3/jpos/lib/jdom.jar
    When build jar, error :
    error while reading original manifest: error in opening zip file
    Building jar: /root/PHASE3/TesterPhase3/IsolibTester/dist/IsolibTester.jar
    Manifest is invalid: Manifest sections should start with a "Name" attribute and not "Main-Class"
    /root/PHASE3/TesterPhase3/IsolibTester/nbproject/build-impl.xml:273: Invalid Manifest: /root/PHASE3/TesterPhase3/IsolibTester/manifest.mf
    BUILD FAILED (total time: 0 seconds)
    So, i tried add classpath in bash_profile and build.xml, unseccessful
    But, when runing my project from terminal can't found component jdom.jar

  • How to include another .jar package in an applet jar package

    Hi, I'm using Eclipse to write an applet which needs some other .jar packages to support it. I add them as external jar package in project properties. In eclipse, everything works fine when I compile and run. But I when export the applet to .jar and try to run in browser, it doesnt work.
    I think probably because I didnt export the packages that the applet requires to run. However I cant find a way to export these packages together with the applet to a final .jar file.
    Anyone knows how to solve this ? plz help. thx you in advance

    Hi, I'm using Eclipse to write an applet which needs
    some other .jar packages to support it. I add them as
    external jar package in project properties. In
    eclipse, everything works fine when I compile and
    run. But I when export the applet to .jar and try to
    run in browser, it doesn't work.
    I think probably because I didn't export the packages
    that the applet requires to run. However I cant find
    a way to export these packages together with the
    applet to a final .jar file.
    Anyone knows how to solve this ? plz help. thx you in
    advanceHi all,
    I have been having the same problems too but came to realize that it is quite difficult getting your applet to work in most cases when using external jars. I found out thet you will have to create the directory hierarchy with the necessary imported classes used by your applet. and then create a new jar file that you will use in the codebase tag.
    For example:
    /* Java code snippet */
    import org.apache.XmlRpcClient;
    public MyApplet extends JApplet {
    //..... Rest of your code ......
    }/* End of snippet */
    You would then have to create a the directory structure:
    org
    _apache
    ___xmlrpc
    Then place all the required classes imported from within (Sometimes it is easier to just add all the classes to save time but lose space i.e. larger jar files).
    Execute the jar command (please adjust as needed to your requirements):
    jar cvf any_name.jar *.class org/
    After signing the applet it may solve your problem. Since I'm working with XmlRpc I still have a lot of problems. If anyone has any advice or tips, please share.
    Thank you

  • How to include external .jar libraries

    hi,
    I'd like to use an external .jar library in my Java program.
    I import the package in the source code.
    But where do I have to specify the file location of the .jar file. Do I have to add its directory to the PATH environment variable or somewhere else??? So far I've done this only in Eclipse, but now I'm working in a pure linux environment... with no IDE.
    Thanks :)

    Or specify the classpath completely when you run javac.
    For example to compile a class called Foo in the current directory which uses classes from an external jar file I would say
    javac -cp .:../../whatever.jar Foo.javaAnd if Foo has a main() class:
    java -cp .:../../whatever.jar Foo(If you are working with a number of projects each with lots of classes and lots of (different) jars, it might be time to look at Ant.)

  • Including other JARs when packaging

    Hello,
    I have read the SUN tutorial on how to package my application, which I was able to do and execute fine. The problem is, in my application I use several database connection jar files, such as mysql-connector-java-5.0.4-bin.jar (MySQL) and jt400.jar (AS/400). When I try to do something in my application that uses one of these jar files, such as when I try to log in (uses a MySQL connection), I receive the following error:
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    My application works fine if its not packaged, but when it is, I receive this error. I tried putting the jar files in the package folder, but that did not help. I tried setting my classpath to those files in the package folder, that as well did nothing.
    Could anyone help, or point me in the right direction?
    Thank you.

    But... it still requires me to extract the lib folder
    out of the jar, and keep it in the same directory as
    my main jar for it to read. I just want to be able
    to double click on it and have it launch, without
    needing to extract anything..That's the idea. You don't need to extract anything if you distribute your entire directory rather than trying to pack those other JAR files into your JAR file. The idea is that they're separate and your JAR file is linked to them. With your command
    jar ... lib/*.jar
    You're actually adding the JAR files to yours, rather than leaving them outside of it and just bundling everything up and distributing it. There's good reason to leave those JAR files separate. For example, when your MySQL driver gets updated you can distribute that single JAR file as an update (and perhaps your own if your code changed) rather than having to bundle everything up again and distribute the entire thing.

  • How to include jdic.jar in my program

    Hi all,
    I'd like to deploy my program and for that i am exporting it in an executable jar using eclipse.
    My program uses some of jdic functionnality so i need to include in my program jdic.jar. But that' s my problem. How can i include it in my application's executable jar.
    thank you for your help.

    Hi,
    Sorry but i don' t understand what you've written, if
    my executable jar is named
    myexecutablejar.jar and the jar that i would
    like to put in in order to work is named
    jdic.jar what would be the command?
    Thanks for your precision.Is this clearer?
    jar cvf myexecutablejar your-classes path-of-jdic.jar

  • How to include libraries properly in an application

    Hello,
    I am working on a project that uses an external device.
    I installed software for this device that includes drivers and libraries (.dlls) to be used with LabView.
    To communicate with the device, I use the "create Active-X object" block.
    As the Active-X input, I create a new input and pick the right class from the drop down list.
    This does not add any dll files to the dependencies of the project.
    LabView seems to be assuming that the necessary files are there.
    I want to install this application on another computer that does not necessarilay have the software for the device installed.
    My application fails. There's no error message of any missing library whatsoever.
    I have to add the necessary libraries manually.
    How should I do this?
    1) I could add the library files to the project directly.
    2) I could add the library files to the installer off my application, so that they are properly installed along with my application.
    I'm not sure how to do this.
    How do I tell the installer to install* the library files?
    (* what I mean with that is to place them in the proper folder. Sure, the application folder is also searched for dlls upon execution but that means every application has its own dll, which seems to be a bad approach)
    3) I could add the Redistributable .exe file to the installer of my application as an installer.
    I'm not sure how to do this either.
    Should I add the .exe file to the project, copy it to some location(which one?)  during installation and then execute that file after the installer finished?
    Or should I add this installer to the list of "additional installers"? It seems like one can only add NI installers. How do I add mine?
    Or is there another way I should do this?
    Thank you for your help.
    Solved!
    Go to Solution.

    Nope, files in Temp are not automagically deleted by default. What you could do instead is either invoke the installer directly from your install media using a relative path or you could write a good 'ol batch file and invoke that instead at the end of your installer. This would start the actual driver installer and wait for it to finish. Then cleanup whatever needs to be cleaned up afterwards.
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • How to include javamail and jaf package in ApacheTomCat Server

    org.apache.jasper.JasperException: Unable to compile class for JSP
    C:\Program Files\Apache Tomcat 4.0\work\localhost\examples\jsp\SendMail$jsp.java:6: Package java.mail not found in import.
    import java.mail.*;
    ^
    1 error
         at org.apache.jasper.compiler.Compiler.compile(Compiler.java:284)
         at org.apache.jasper.servlet.JspServlet.loadJSP(JspServlet.java:546)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.loadIfNecessary(JspServlet.java:177)
         at org.apache.jasper.servlet.JspServlet$JspServletWrapper.service(JspServlet.java:189)
         at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:382)
         at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:474)
         at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
         at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)
         at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)
         at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:243)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:201)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:472)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2344)
         at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:462)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:564)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:163)
         at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:566)
         at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472)
         at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943)
         at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:1011)
         at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1106)
         at java.lang.Thread.run(Unknown Source)

    hey pnarkodu
    put your activation.jar and mail.jar packages in the
    /tomcat_directory/common/lib - there are a bunch of jars here and just include the above two here
    then stop and run tomcat again
    think this will work
    let me know
    sincerely
    laodingsockjavaguy

  • How to include applet jars into an JSF application

    Hey guys,
    I have a rather simple question. I have made a JAR that contains an applet. The applet runs fine, but when I include the applet into a JSF / JSP page I get a Class not found error.. The JAR containing the applet is included in the websites build path.
    Can someone give me a hint where the JAR shoud go? Maybe a link to a tut would be nice

    classpath wasnt set correctly

  • How to include resource files in the server classpath

    Hello,
    I deployed an EAR on weblogic. I have couple of resource files that I need to put in the server classpath. I get the following error when I try to access the web app.
    java.util.MissingResourceException: Can't find bundle for base name HtmlTemplates, locale en_US
    If I copy the resource files in WEB-INF/classes then the error goes away and the application works well. Can someone please tell me a better way to include the resource files in the WebLogic ?
    Thanks,
    Anu

    Hi Anu,
    Putting the resource files in WEB-INF/classes is the correct and good way!
    Simon

  • How to includ jar files?

    Hi,
    I am having jar file and iam running that jar file in command prompt using java -jar WorkFlow.jar command. I have to include some additional jar files in classpath while running this WorkFlow.jar file... Anyone please tell me how to include the jar files in java command??
    Thanks,
    Sathish

    Sathishkumar.D wrote:
    Hi,
    I am having jar file and iam running that jar file in command prompt using java -jar WorkFlow.jar command. I have to include some additional jar files in classpath while running this WorkFlow.jar file... Anyone please tell me how to include the jar files in java command??
    Thanks,
    SathishYou can't. The WorkFlow.jar you have them specified in the class path entry in the manifest file.

Maybe you are looking for

  • Problem in picking base value from PO while doing goods receipt for multiple POs

    Hi, Our user is trying to post goods receipt for two purchase orders which have same vendor. After the materials of two POs are allocated in the item detail screen and checked the item ok, system throwing error as "Please check the base value of the

  • How to transfer ringtones from iphone to itune

    i am trying to transfer ringtones that i download from an app to itune but i download itune on my pc and connected with iphone but dont know what to do next

  • Help non profit hospice! how do I addfile name & page number into each pg of a large amnt of files!

    First thanks for reading this..... I have to add the patient name and page number as a footer to hundreds of scanned documents.  The person scanning can call each file the patient last name.  So file is named Smith.  Any way I can have it automatical

  • How to connect to oracle9i database from Unix

    Hi All, How can i connect to remote oracle9i database(windows based) from Unix. I have following server information Server IP, Username , Userpassword , DataBase name.Do i need any other information to connect to server? How can i connect database fr

  • Dvorak in French

    Hi everyone! I was surfing when I saw an article about Dvorak keyboard layout. I thaught it was interesting, and I looked everywhere to activate it! I found two Dvorak Keyboard layout in my Intl.prefpane, but as the article described it, Dvorak is sp