How to set Classpath fro Jar executable archive

Hello,
I'm a java programmer since 4 years, but it's the first real desktop application I develop (always build web apps).
I've developed an application that connect to a DB using the mysql java driver
I've pachaged all in a jar that is structured like this:
agenzia.jar
Agenzia\
Agenzia.class (the startup class)
application classes
mysql-connector-java-2.0.14-bin.jar
and in the manifest I add this 2 lines:
Main-Class: agenzia.Agenzia
Class-Path: mysql-connector-java-2.0.14-bin.jarthe program works fine on my PC, but when I copy the jar in another PC it gives me a ClassNotFoundException not loading the mysql driver...I mean I can see the UI, but when I connect to the DB it gives me the error... I run the program double-clicking on the filename (in windows)
Does anybody know how to solve this problem?
Thank you
Simone

I've also noticed that if I take the mysqldriver out of the jar, put it in the same dir as the agenzia.jar everything works fine.
Thank you
Simone

Similar Messages

  • How can i create a jar executable archive

    I could not find the way to create an executable archive from Oracle JDeveloper 10.1.3.3.0 .
    I have an application and a project with many packages that i want to archive.
    If somebody could help please .

    Well i red somewhere that It is also possible to make an archive that can be executed (run) by Java and even by a double click through your OS, if you have it set up correctly and that is what i want to do , a jar file which embraces all my packages and run a specified Main class.

  • How to set Classpath for MySQL

    Hi
    I want to connect to my mySQL db with a java program , but I don't know how to install the mySQL connector driver. Can anyone help me? or indicate somewhere where I might find the answer?
    And how to set Classpath for MySQL.
    my program gives an exception ClassNotFound.
    Exception :com.mysql.jdbc.Driver
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
    at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
    at java.lang.Class.forName0(Native Method)
    at java.lang.Class.forName(Class.java:164)
    at Files.main(Files.java:352)
    Plz help me
    Thanx
    Lalit

    to make your life easy i tried to connect..
    what you have to do is.. you mysql database server should be running
    next you have to download one of the version of mysql driver.. i downloaded mysql-connector-java-5.0.5
    go to my computer right click - >advance tab -> click on environment variable -> put you path e.g. C:\Program Files\Java\jarFiles\mysql-connector-java-5.0.5\mysql-connector-java-5.0.5-bin.jar
    into your classpath in a user variable section..
    Try this code
    import java.sql.*;
    public class MySqlConnect{
         public static void main(String [] args){
              try{
                   Class.forName("com.mysql.jdbc.Driver");
                   String url ="jdbc:mysql://localhost:3306/test";
                   Connection con =DriverManager.getConnection(url,"root", "password");
                   System.out.println("Connection: " + con);
              }catch(ClassNotFoundException cnfe){
                   cnfe.printStackTrace();
              }catch(SQLException se){
                   se.printStackTrace();
    }have fun
    Gurnah

  • In UNIX how to set classpath

    I know nothing about UNIX. pls kindly give me some instruction on how to set classpath in UNIX, thanks!

    best way is to set in your .profile (name differs between different shells, but whatever the OS/Shell is, it should starts with . and has a 'profile' string in the name). Try ls -a to find the file, edit it, insert lines like this:
    CLASSPATH=xxxx
    export CLASSPATH
    Use : to seperate different path/files.
    then every time when you log in, the classpath is setted.
    if you already logged in, use the above lines in command line, but it only set class path of the current shell/console.
    anyway, you should learn Unix before you do anything, or you'll have more trouble. do a search in yahoo or google to find on line tuturials, and SUN's Java tuturial has some basic instructions on how to use Java in Unix.

  • How to set classpath in WinXP Home edition

    Hello everyone,
    Recently I have try to run the HelloWorld java code, but it come up with a error. (Exception in thread �main� java.lang.NoClassDefFoundError: HelloWorld)
    Java programming Code:
    public class HelloWorld {
    public static void main (String args[]) {
    System.out.println("Hello World!");
    I also try to compile another simple program, and it come up with the simpler error, (Exception in thread �main� java.lang.NoClassDefFoundError: Add16And23)
    Java programming Code:
    public class Add16And23
         public static void main (String[] args)
              int sum;
              sum=16+23;
              System.out.println("The sum of 16 and 23 is " + sum);
    HOW CAN I FIX THIS, I read other threads before, it say some about class path.
    Do anyone know how to set it, in winXP?
    Do anyone know the whole path that I should put in, in winXP?
    What should I type in the (User variables for windows) and (System variables).
    I have :
    * (j2eesdk-1_4-dr-windows-eval) downloaded and installed;
    *WinXP Home edition Version 2002 Service Pack 1
    * My current Java path are (C:\Sun\AppServer\jdk\bin) in the (User variables for windows).
    Please help!!!
    Thank you all!!!

    I'm also windows xp.
    fllowing example:
    java_home=c:\j2sdk1.4.2_03\bin
    classpath=c:\j2sdk1.4.2_03\dt.jar;c:\j2sdk1.4.2_03\tool
    .jarThis won't fix a thing.
    When you run, do it like this:
    java -classpath . HelloWorldNote the "dot" after -classpath. That tells the class loader to look in the current directory for the .class files it needs.
    Read about how to run the javac.exe and java.exe tools in your javadocs. You'll have to learn about CLASSPATH. - MOD

  • How to set classpath from java class ??

    I have tried to use System.setProperty("java.class.path", "my class path string ") to set classpath dynamically. But it is not working. How to set it dynamically from java class ?? Thanks , gary

    Look into the java.net.URLClassLoader. You can't set the classpath after the fact but you can specify URL's that will checked when you try to load a class with that loader.

  • How to Set CLASSPATH in Apache Web Server Using IAS

    Hi,
    I have problem setting the classpath for the servlet I am using for file uploading...My work environment is Web Server is Apache with Oracle8i IAS on Sun Solaris..
    I have tried various method like setting wrapper.classpath=/oracle/ias/Apache/Jserv/servlets and my class resides under /oracle/ias/Apache/Jserv/servlets/com/oreilly/servlets/MultipartRequest.class
    in the Jserv.properties, still it get the error message class ...not found in type declaration when I compile the code...my reference to the servlet in my JSP code is com.oreilly.servlet.MultipartRequest ..
    Can someone help me out please, if you have have any idea of how to set the class path with the working environment I have specified ealier....
    null

    have you posted this on the ias 9i forum where the ias 9i apache experts are at ??

  • How to set path to jar file (classes)?

    hi,
    i have a java program which uses a jar file (lots of classes). so, i run them all in eclipse but i want to run it on a command line, like through cmd from run.
    the classes are found in a different folder, and the code snippet is found in another folder. so where or how to set the path to the jar file?

    Write
    c:/java -?
    you can use the -cp pption to use your jar file or a folder with classes.
    java -cp jar1.jar myclass.class

  • How to set classpath for J2ME

    how to set class path for j2me. I downloaded J2ME Wireless tool kit. And set the classpath "set classpath=c:\J2mewtk\lib\midpapi.zip;.;". but i could compile java file. .how to set.
    With regards
    Santhosh

    When you are downloading j2MEWTK, everything is included within it. You dont require MIDP seperately. When you are runnung the ktoolbar , which is provided with J2mewtk, the preverifier runs and creates the required jad file for you. You dont need a forte to run these.
    If you want to download MIDP seperately, that also is possible. Then you have to go for command line arguments. Please refer to Sun's MIDP page for details.
    Let me know, if you face any further problem

  • How to set classpath and server configuration in eclipse

    i am new to eclipse tool pls anyone tell me to set classpath and serverconfiguration (tomcat) and sample program

    Get WTP [1], install it [2] and checkout one of the lot Eclipse WTP tutorials [3].
    [1] http://www.eclipse.org/webtools/
    [2] http://ftp.osuosl.org/pub/eclipse/technology/phoenix/demos/install-wtp/install-wtp.html
    [3] http://www.eclipse.org/webtools/community/tutorials/BuildJ2EEWebApp/BuildJ2EEWebApp.html

  • How do I put my jar executables into a cab file to create a setup/install?

    I want to create a setup program for installing my jar executable. I've seen ones that create cab files with a setup.exe program and would like to do the same. Any suggestions?

    Well, JARs generally don't have support files. That's the whole idea. A JAR is designed to be a stand alone application. You don't really need to install it, for that matter. I just thought you might be wanted shortcuts or something.
    Actually, there is some way to install Java programs through Java Web Start, if you want to check that out. I don't know anything about it, though.

  • How to set classpath to use imported packages?

    Hi all,
    a real newbie question:
    I have created a class in which i import the java.io package. I can compile this class with the Oracle JDeveloper IDE (this is a variation on JBuilder).
    The problem is that i can't run this class because (most probably) the java.io package is not in the class path.
    Which jar file should i include in my classpath?
    jdk1.3\src.jar
    or jdk1.3\lib\tools.jar
    or jdk1.3\lib\dt.jar
    or ...
    Where can i find information on this? How can i find structure in the jungle of classes and packages?
    thanks, Bart

    If you want to execute this class file there are two ways you can do this:
    First set your environment PATH:
    Second you can explicitly state the classpath: for example
    change to the directory with the class file:
    cd c:\progra~1\Oracle\JDEVEL~1.0\MYCLAS~1
    while in the directory type
    java -classpath c:\progra~1\Oracle\JDEVEL~1.0\MYCLAS~1 HelloWorld
    Hope this helps.

  • How to set classpath to take classes in conf \ jboss.service.xml file

    Hi,
    I just want to put some classes which are in a package say 'mypack' in the lib folder . In the jboss.service.xml file the classpath is set to codebase="lib" archive=" * " > but this won't work for classes which are not in any of the jar files. how to do this?.. pls help me.
    Thanks in advance
    Sudheer

    Could you package your classes into a jar file?
    Fil

  • How to set classpath for classes in war files

    Hi All,
    After deploying the WAR file I could access the JSP files but gives classnotfound exception when the information is expected from the java servlet.DO I need to set the classpath if yes how to do for the war file.
    thanks

    The web.xml,file structure and error is below let me know if more information is required.
    As you said weblogic is looking for the classes in lib directory inspite of having the classes in web-inf/classes directory.
    web-app>
    <servlet>
    <servlet-name>ControllerServlet</servlet-name>
    <servlet-class>com.test.site.pds.Controller</servlet-class>
    </servlet>
    <servlet-mapping>
    <servlet-name>ControllerServlet</servlet-name>
    <url-pattern>/controller</url-pattern>
    </servlet-mapping>
    <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    </welcome-file-list>
    </web-app>
    File Structure:
    C:\test\PDSWebApp\WEB-INF\classes\com\test\site\pds\*.class
    PDSWebApp
         css
         html
         images
         javascript
         jsp
         WEB-INF
         classes
         com/test/site/pds/*.java
         lib
         servlets
    The error:
    javax.servlet.ServletException: [HTTP:101249][ServletContext(id=18129862,name=PdsApp,context-path=/PdsApp)]: Servlet class com.test.site.pds.Controller for servlet ControllerServlet could not be loaded because the requested class was not found in the classpath C:\bea\user_projects\domains\mydomain\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\PdsApp.war;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\classes12.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\commons-beanutils.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\commons-collections-2.1.1.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\commons-lang-2.0.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\displaytag-1.0.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\jstl.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\WEB-INF\lib\standard.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp\jarfiles\_wl_cls_gen.jar;C:\bea\user_projects\domains\mydomain\.\myserver\.wlnotdelete\extract\myserver_PDSAPP_PdsApp.
    java.lang.ClassNotFoundException: com.test.site.pds.Controller.

  • Set classpath fro 9ias

    Hi,
    I am trying to install 9iAS on Linux, but when I start the Installer I get the error message:
    Initializing Java Virtual Machine from /tmp/OraInstall2004-08_11-18-03AM/jre/bin/java. Please wait...
    Exception in the thread "main" java.lang.NoClassDefFoundError: Enterprise
    Hence, the Oracle Universal Installer cannot be executed.
    I has set up the the $CLASSPATH variable as follow:
    CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/network/jlib
    export LD_ASSUME_KERNEL=2.4.1
    Any help please? Thank you!

    I've also noticed that if I take the mysqldriver out of the jar, put it in the same dir as the agenzia.jar everything works fine.
    Thank you
    Simone

Maybe you are looking for

  • Safari won't open in ipad mini ios7 ?

    safari on ipad mini ios7 won't launch. in usage data it using 1.1 space. checked restrictions re booting etc. any help is après hated

  • RE:JOB TERMINATED IN SOURCE SYSTEM.

    Hi Gurus,               In production environment while we are trying to load data we recived follwing error message. Error message from the source system Diagnosis An error occurred in the source system. System Response Caller 09 contains an error m

  • Cisco MSE CMX dashboard

    Hi, I have some problem with CMX dashboard configuration, I followed the configuration guide (http://www.cisco.com/c/en/us/td/docs/wireless/mse/7-6/CMX_Dashboard/Guide/Cisco_CMX_Dashboard_Config_Guide.html) and can't understand, how do I add a map to

  • Aperture 2 and Nikon D7000

    Uploading NEF files from my new Nikon D7000 to Aperture 2 gives me an "Unsupported Image Format" error message. JPGs are fine. I do not see any software updates from Apple to resolve this problem. I'm hoping that I don't need to upgrade to Aperture 3

  • Error -2048 QT / Win XP PRo

    Hello, I have been trying to get a .MOV file to play which a client has sent me showing a fault. Error 2048: Couldn't open the file xxx.MOV  because it is not a file Quick time understands. How can I play this file?  Other QT files play.  Where can I