External jar question

hi all,
I made a Java application in Eclipse;
in Project - Properties - Build Path - Libraries, I added an external jar to be able to connect to a mysql database.
Now I can execute this application perfectly from Eclipse and on the same machine.
But now I need to put this application on another machine, but when I try to execute the application it gives this error message:
$ java WatchDog
Cannot connect to database serverorg.gjt.mm.mysql.Driver
Exception in thread "main" java.lang.NullPointerException
at Query.truncate(Query.java:304)
at WatchDog.<init>(WatchDog.java:18)
at WatchDog.main(WatchDog.java:131)
I also tried to point to the external jar with the -classpath option like this:
$java -cp "/usr/local/bin/WatchDog/mysql-connector-java-5.0.4/mysql-connector-java-5.0.4-bin.jar" WatchDog
Exception in thread "main" java.lang.NoClassDefFoundError: WatchDog
how can I do this??
grtz
Message was edited by:
dfvdfvdfvxfv

by setting the classpath like that you removed your own classes from the classpath.
Add the directory where those are to be found to the classpath as well.
And of course ALWAYS use packages for your classes.

Similar Messages

  • DownloadService.loadResource for external jars for 1.6.0-19+

    First, be kind with my english, i'm french (nobody's perfect...)
    I have a JNLP into which i declare a signed jar resource main.jar. This application retreive at execution a list of signed jar names (+a.jar, b.jar+...) that i dynamically load on my need through DownloadService.loadResource. My a.jar, b.jar are cached and it rules! But if i made a new main.jar, a.jar and b.jar, and deploy them on my server, here what's happend:
    - main.jar is tested for modification date on server (thanks to "If-Modified-Since" HTTP header), cache date is before this date, so JWS update main.jar by downloading this new main.jar. This is the behaviour described into specs and it is perfect for me!
    - but for others resources (a.jar, b.jar) i was excpected the same behaviour but JWS does not seems to check for modification date. So a.jar and b.jar are not updated.
    So my first question: Is there a way to tell to DownloadService.loadResource to check for modification date? i could deal with jar version but this basic date checking was great for me...
    Except this cache minor problem, external jar download works just fine except i get the warning security problem [Mixing Signed and Unsigned Code |http://java.sun.com/javase/6/docs/technotes/guides/jweb/mixed_code.html].
    All my jars are signed with the same certificate, so i was a bit confused.
    Anyway, i follow indications and put the Trusted-Only: true attribut into the manifest of main.jar.
    But it leads to this exception:
    java.lang.SecurityException: Trusted-Only loader attempted to load sandboxed resource from http://monserveur/a.jar
         at com.sun.deploy.security.CPCallbackHandler$ParentCallback.check(Unknown Source)
         at com.sun.deploy.security.CPCallbackHandler$ParentCallback.access$1400(Unknown Source)
         at com.sun.deploy.security.CPCallbackHandler$ChildElement.checkResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath$JarLoader.checkResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath$JarLoader.getResource(Unknown Source)
         at com.sun.deploy.security.DeployURLClassPath.getResource(Unknown Source)
         at java.net.URLClassLoader$1.run(Unknown Source)
         at java.security.AccessController.doPrivileged(Native Method)
         at java.net.URLClassLoader.findClass(Unknown Source)
         at com.sun.jnlp.JNLPClassLoader.findClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at java.lang.ClassLoader.loadClass(Unknown Source)
         at my.package.a$5.run(a.java:348)
         at java.lang.Thread.run(Unknown Source)I found some posts that deal with similar problems but it does not give me a working solution. The difference seems to be the fact that i load external jars (not defined into JNLP).
    My JNLP is validated though JaNeLA.
    I cannot set a.jar, b.jar as resources into jnlp because i retreive their location during execution...
    My JNLP also declare:
    <security>
            <all-permissions/>
    </security>I think i'm a bit confused with the sandbox notion and the Trusted-Only: true attribut of the manifest. I also tried to add it to a.jar, b.jar and not main.jar but vainly. I also tried to set it on all jars but it does not work better.
    Is there a way to load external jar without having the Mixing Signed and Unsigned Code warning popup? What do i not well understand?
    Sorry to be so chatty...
    Thanks in advanced for any answer.

    So, I finally succed in finding a solution.
    But this solution seems perhaps a barbarian way to solve my problem but it works.
    The idea (as far as i understand) is that when you define "all-permission" into JNLP file, then these permission are granted for JNLP ClassLoader. When you load external jar through DownloadService.loadResource, then another classloader is used. It seems that this classloader does not inherit security policy from JNLP ClassLoader.
    My solution is to define my own policy:
    Policy.setPolicy(getAllPermissionPolicy());
        * @return a {@link Policy} with all permission granted
       private Policy getAllPermissionPolicy()
          Policy policy = new Policy() {
             private PermissionCollection m_permissionCollection;
             @Override
             public PermissionCollection getPermissions(CodeSource p_codesource)
                return getAllPermissionCollection();
             @Override
             public PermissionCollection getPermissions(ProtectionDomain p_domain)
                return getAllPermissionCollection();
              * @return an AllPermissionCollection
             private PermissionCollection getAllPermissionCollection()
                if (m_permissionCollection == null)
                   m_permissionCollection = new AllPermission().newPermissionCollection();
                   m_permissionCollection.add(new AllPermission());
                return m_permissionCollection;
          return policy;
       }For sure, you can decline this with permission you need. Here, all permission are allowed.
    I'm not quite satisfied because it's seems to be a barbarian style solution. But for now, it fits my uses => no warning popup!
    If anybody has a more proper way to deal with such an issue, i'll be glad to hear it!
    Hope it helps.

  • How to use external JARs in Eclipse

    Hello.
    I created a jar file like that:
    jar -cvf0 WarShell.jar WarShell.class
    I want to use WarShell.class in Eclipse but it not in my classpath,so I choose [Project] -> [Properties] -> Java Build Path -> Libraries -> Add External JARs and add WarShell.jar to the list.
    But when I run the program I got a Exception:NoClassDefFoundError.
    Why?How to fix it?
    Another question... Your classpath is not available in Eclipse,right?
    Thanks for your time! ^_^

    Hello.
    I created a jar file like that:
    jar -cvf0 WarShell.jar WarShell.class
    I want to use WarShell.class in Eclipse but it not in
    my classpath,so I choose [Project] -> [Properties]
    -> Java Build Path -> Libraries -> Add External JARs
    and add WarShell.jar to the list.
    But when I run the program I got a
    Exception:NoClassDefFoundError.
    Why?How to fix it?Did you run your program from Eclipse ?
    If yes, it should work (or seek for an Eclipse-specific forum.)
    But if not, keep in mind that your project settings are limited to Eclipse. You'll have to define a correct classpath for running your application.
    Another question... Your classpath is not available
    in Eclipse,right?Mine? I don't think it is available for anyone ;-P

  • How to add external jars in the configuration of JSmooth?

    Hello,
    I am trying to create an exe file from a java program using JSmooth.
    The program is a simple hello world proogram.
    I am developing under eclipse, and I am using some external jar files as libraries.
    If my program is simple,; it works fine. If I add an import of a class that is in one of these jar files, I get the following error when executing the created .exe file:
    "Could not find the main class. Program will exit".
    I guess I have to add this Jar file to the path for the creation of the .exe file.
    My question is: does anybody know HOW to add an external jar in the configuration of JSmooth for the creation of an exe file from a Java program?
    Thanks for your help
    Philippe

    i have the same problem phsans
    you know the answers??
    thanks phsans:D

  • General JAR Questions 101

    I just completed my first ever app using the Netbeans IDE 3.6 w / sdk 1.4.2_04
    My GUI app has a main class name of : "AddRFSwitchMain" residing in a package named "AddRFSwitchPac" all in a project folder named "OW_A"
    My app requires the resources of an external multi -container "OneWireAPI" jar file.
    My app also makes use of the timer bean that came already residing in the netbeans IDE bean palette.
    All of the GUI code was constructed by using the GUI form builder tool including the timer bean56.
    Question:
    (1) To run my app outside of the IDE, I created a "jar file recipe" named "OWProject" This OWProject recipe then becomes my "compiled jar" named "ProjectOW" and runs fine when mounted "inside" the IDE . It looks to me like my "ProjectOW.jar" only makes "file location references" to the needed external "OneWireAPI.jar" I thought that my jar file would contain the "actual files" of the needed "external files" inside my jar .... is this not true? ..... as it stands, to run my app as a stand alone on another computer , with an installed "jre" , I would need to also include the "OneWireAPI".jar also to be installed on a computer running my app.
    (other questions to follow this one)

    >
    OK ... so ... "third party software" is only made
    reference to its "location" as spec'd in my app's
    manifest.
    .... and I do this in the " Class-Path: " of my app's
    manifest.Yes. (see below)
    >
    .... and I can include the "external jar" in my app's
    package for transport to other computers as one Jar.I'm not sure if that would work. (a jar within a jar). ??
    How about something like this:
    \Package Folder\
         - MyApp.jar (the main jar)
         \bin\    (folder)
              - Other Jar needed for execution of the programThen in your main jar's manifest, include "bin/OtherJar.jar".
    So the second jar will be packaged separately, away in a folder that clearly states what it contains.
    All the user would have to do is to execute the main jar. this is the only file they would have to see, from an
    execution perspective.
    Question:
    (2) As my app now stands in the netbeans IDE , my app
    "imports" these required external files from thier
    respective locations "mounted" in my IDE. ... When I
    move these external files to my "Package folder" ..I
    must now go back into my app and change any location
    reference (import statements, etc) to reflect this
    move ... correct?I don't think so: as long as your classpath (got from the manifest of the jar) includes the new locations of
    these external files.
    I think NetBeans works like this: a 'mounted' directory or file is included in the classpath.
    ie. when you click 'Compile', NetBeans passes a command to javac, specifying a few different parameters,
    and including in the classpath all the mounted files and directories (looks something like:
    "javac -classpath .;C:\Programming\Java;C:\Java\ThirdParty\OneWire; etc.", where those directories
    specified in the '-classpath' parameter are the mounted directories)
    So when you move your app out of NetBeans, all you need to do is to ensure that the required files are
    included in the classpath. If you're still working on your app in an editor, you'll need to tell the editor what to
    include in the classpath (that's how IDEs make your life easier*).
    If you are packaging your app as a jar file, you will need to specify (in relative locations) where your
    required files will be located.
    Your actual code should not need to be modified.
    Does this make sense?
    :) lutha
    * but, as you can see, they should perhaps only be used when the programmer already understands concepts like classpath! ;-) This is the view of many programmers here on these forums.

  • Load external .jar into Servlet

    Hi...
    I'm trying to load an external jar file into a Servlet and I'm getting some problems.
    I'm using URLClassLoader to get the class from the jar, but, everytime I try to get a parametrized constructor from the class (as shown below), a NoSuchMethodException is thrown.
    I can do that by a external Java Application, but not inside Servlet.
            try{
                constructor = clss.getConstructor(CoopServerInterface.class);
            } catch(NoSuchMethodException ex){
                ex.printStackTrace();
            }Could anyone help me?
    Thanks!
    Edited by: Jaumzera on Aug 1, 2008 11:22 AM

    Show us the exception.
    Does the class in question have a constructor that takes a CoopServerInterface parameter? I.e.
        WhateverClassTheClssVariableIs(CoopServerInterface x) {
        }If the constructor exists, have you deployed that version of the compiled code to your web server? Check that you have. Chances are you have an old WhateverClassTheClssVariableIs.class file somewhere that doesn't have the constructor, and the web server is using that class file. Or you need to restart the web server so it notices the new version.

  • Exporting External JARs on WAS from Webdynpro

    Hello everybody,
    I have posted same topic earlier also. But i can't any solution for that. Bharadwaj has suggested to make Library project and add all JARs in it and deploy on WAS. But in Library projects, we can only add JARs of Exsisting projects only.
    So, what could be other options for that?
    Thanks in advance,
    Bhavik

    Hi Bhavik,
    Sorry for a very very late reply. I think it is a limitation (or probably a bug ) . What i do usually is ,add it to some other project's lib folder and then take the jar from there. Since it is added as a seperate copy in ur .sda file it wont be problem after deploying. No reference exists.
    Its just that u wil have a problem while adding it design time..
    Its a round about way to take a jar.But it works.
    And about ur question.. i doubt if u can really find the jar in the bin folder directly.. (If we add a external jar to project i cant find any jar in the project folder. I searched the .ear file but i am not able to find it. Just check if u can find it )
    Regards
    Bharathwaj
    Message was edited by: Bharathwaj R

  • How to use one external jar (SDK) for several apps in WTK?

    Hi,
    I have one external jar (SDK) I use for developing J2ME applications.
    Every time I have no choice but to copy this JAR (SDK) into my current application lib directory.
    I am building a family of MIDlets that I dont want to put into just one huge JAR but rather to have several JAR files for each application.
    In C world I need only to tell the linker where it should pickup ".so" or ".lib" file.
    Is any way to do the same with WTK? Or any other J2ME development tool?
    Thanks in advance,
    Andrew

    Link to wtk2.5 beta has been posted to this forum
    while ago. It's worth to try it It is MSA1.0
    compliant. It has many new JSRs.TomTom,
    Thanks again.
    I tested the WTK2.5BETA and here I ahve strange fact. My application works perfectly on WTK2.1, WTK2.2 WTK2.3 BETA but it crashes with a very weird message on WTK2.5BETA
    Method............: 22482ac 'com/tinyline/app/SVGEventQueue.handleEvent (virtual)'
    Stack Chunk.......: 2216e44
    Frame Pointer.....: 2216e7c
    Current IP........: 224820b = 22481fc + offset 15
    Previous Frame....: 2216e58
    Previous IP.......: 226afd6 (offset 26)
    Frame size........: 3 (2 arguments, 1 local variables)
    Argument[0].......: 20bc0b8
    Argument[1].......: 2216d7c
    ALERT: java/lang/NoSuchMethodError: No such method dispatchEvent.(Lorg/w3c/dom/events/Event;)Z.
    So I thought, OK it was compiled under WTK2.1 may it was the reason of crash.
    I took sources and compile them under WTK2.5 BETA. I came up with the same result - crash.
    Thanks,
    Andrew

  • Getting error while calling external Jars in BPEL by using Java embedding activity in soa 12c

    Hi,
    I am trying to use an external Jars for the business logic implementation. Here I need to pass XML as input and
    and I expect the "Password " field has to be return.
    Following are the steps I have followed:
    1) Created a java project with sample class and added the external jars into the project "Libraries &Classpath".
    2) Created a jar file out of it.
    3) Created a BPEL project with Java Embedding.
    4)Wrote the java code in java embedding activity.
    4) Added the above created jar file to the BPEL project's lib/jar  and added in SCA-INF/lib project folder as well.
    5) Imported the package with the class as in the jar (e.g <bpelx:exec
    import="pkg.testInterface"/>)
    6) Deploy the BPEL project.
    while deploying the SOA build is sucessful but my depoyment is incomplete.
    error:
    advices will be great....
    Regards,
    Dilip

    Hi,
    Can you confirm if the BPEL Version is 1.1 or 2.0.
    If you are using BPEL 2.0 you need to import the required jar/class file as:
    <import importtype="http://schemas.oracle.com/bpel/extension/java" location="pkg.testInterface"/>
    For BPEL 1.1 the syntax to import other jar/class file is:
    <bpelx:exec import="pkg.testInterface"/>
    If you import the classes in the correct format you will not face any deployment error.

  • Help need in Adding External jar files.

    Hi all,
    Iam developing ADF application using JDEV 11.1.1.3.0.
    I need to move files from one directory to another so i have used external jar "commons-io-1.4.jar" file.
    i did this by going to the project properties -->Libraries and Classpath -->Add Library
    added the jat file.
    In java class i have used the function
    File.copyFileToDirectory(reQueueFile, TargetLocation,false);
    it was working fine when i tried in IntegratedWeblogic server but when i deploy in Standalone Weblogic server its not getting the jar file.
    Its throwing me the exception
    javax.el.ELException: java.lang.NoSuchMethodError: org/apache/commons/io/FileUtils.moveFileToDirectory(Ljava/io/File;Ljava/io/File;Z)V
    at com.sun.el.parser.AstValue.invoke(AstValue.java:161)
    at com.sun.el.MethodExpressionImpl.invoke(MethodExpressionImpl.java:283)
    at org.apache.myfaces.trinidad.component.UIXComponentBase.broadcastToMethodExpression(UIXComponentBase.java:1303)
    Please let me know is there a way of adding the lib to the project.
    Regards,
    Suresh kumar.k

    First you should check that the library has the checkbox 'Deploy by default' is checked for your library.
    The you open the project properties of the view controller project, select Deployments, edit the deployment descriptor. Select the Node 'File Groups'->'WEB-INF/lib'->'Contributors'. this should give you a list of libraries your project uses. Check if your library has the checkbox checked (is selected fro deployment). If it's not checked, set it.
    This should include the library.
    Timo

  • Including External JARs for Java Application in OC4J

    Hi Experts,
    Here is my requirement.
    I have developed my Java application using Tomcat Server & Eclipse. In my application I have used some External JARs & imported the classes in my JSP.
    Now that I'm using OC4J Server instead of Tomcat I'v no clue as to where I have copy these External JARs for my application to work.
    I have installed OBIEE-Client which includes OC4J server. The path where I have placed my application is as below
    *"C:\OracleBI\oc4j_bi\j2ee\home\default-web-app"*
    If I run my application the server does not import the classes in the JSP which we include using Import statement using JSP tags (*ex* - <%@ page import = "org.apache.commons.fileupload.*"%>).
    This is the location which I found, where I need to put my Java-J2EE application. This OC4J_BI comes with OBIEE.
    Kindly help me out on where to place these External JARs exact location in OC4J.
    Also let me know if I have to alter any configuration/xml file (if so pls specify the file name & its location).
    Thanks in advance,
    Venky

    You can either include the external libraries in the application, by placing them into WEB-INF/lib, or you can import them into the server as "shared libraries", normally you'd use the "enterprise manager" application to do this. Having loaded a shared library you then add it to the classpath when you're deploying the application.

  • 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 call external jar files in EJB project for CE

    Hi,
    I would be thankful if someone could help me with this -
    I need to call the external jar files into my EJB project - Here is what I have done and am getting runtime exception as  -
    java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/glance/pdf/pt/PTDoc
    1. Created a EJB  project" HelloWorld "  using Java perspective in NWDS 7.1 called with client as HelloWorldClient and EAR project as HelloWorldEAR.
    2. Am working on HelloWorld project (1st one).
    3. In my code I am instantiating a class which is a class in one of  the external jar file that I need to refer in my project.
    4. I have set the Java Build path but it works only for the compile time and fails during runtime.
    5. Have read I need to create external library DC and refer in my project "HelloWorld".
    Can anyone help me with exact steps what needs to be done - during creation of external library project and then for my "HelloWorld" EJB project. How would I be able to reference or set the external library project in my EJB project?
    Looking forward to hear from experts.
    Thanks,
    Shiv
    Edited by: Shiv Khullar on Aug 30, 2010 9:39 PM

    Hi Edson,
    I tried it , but it still gives me runtime exception.
    javax.ejb.EJBException: nested exception is: java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/glance/pdf/pt/PTDoc
    java.lang.RuntimeException: java.lang.NoClassDefFoundError: com/glance/pdf/pt/PTDoc
    Steps I performed are -
    1. Created a library project and created 2 Public parts "Compilation" and "Assembly"
    2. Build the library project.
    Now in my EJB project using Project Explorer - set the classpath and added both compilation jar and assembly jar files.
    This is how the classpath entries for external library looks like -
    <classpathentry kind="lib" path="/LocalDevelopmentLocalDevelopmentexternallibrarypdftoolsforwatermarkingdemo.sap.com/gen/default/public/WatermarkAssembly/lib/java/demo.sap.comexternallibrarypdftoolsforwatermarking~WatermarkAssembly.jar"/>
         <classpathentry kind="lib" path="/LocalDevelopmentLocalDevelopmentexternallibrarypdftoolsforwatermarkingdemo.sap.com/gen/default/public/WatermarkCompilation/lib/java/demo.sap.comexternallibrarypdftoolsforwatermarking~WatermarkCompilation.jar"/>
    I have also added the jar files I used in my external library project as "User Library" from Java Build Path . I dont do it , then the code fails during compilation itself.
    Regards,
    Shiv

  • How to handle External Jar files in EJB DC

    I have created a EJB DC.
    I have added the required MDM Jar files to the class path.
    These MDM Jar files are supplied by SAP for integration with Master Data Management.
    But the DC build fails.
    If I create the same project as a <b>REGULAR</b> EJB (non-dc approach)project, everything works fine.
    Qn:
    How to bundle the MDM jars (External jars)in a DC?
    How to create the Public Parts in the DC for the added MDM External Jars?
    How to use the above DC in the EJB DC?
    Basically, I am looking for a step by step procedure,
    to add external jars in a DC.
    And to use the above DC in a EJB DC.
    Any assistance in this regard is appreciated.

    You should not reference the MDM jar files by setting classpath directly. For setting references to it from your EJB DCs , you will have to create a DC of type "External Library". Deploy this DC also before your EJBs are deployed. You will then have to create a public part for this DC and the reference the public part from the DC metadata of the EJB DC ie set the Used DC list of EJB DC to the public part of the ext lib. You will get info about this in NDS help as well on help.sap.com

  • How to include an external jar file in .EAR project

    Hello All,
    I have created a web service through java class in sap netweaver 7.1.
    For database connection i want to add external jar file as reference. could you all please tell me how to do this or can i get some scenario where it is explained.
    Please Help
    Regards,
    Vanita Jain

    Hi Vanita,
    open your project in nwds > right click on the project > click on properties option from the menu > click on java build path from the left-side navigation of the window > and click on libraries in the right side tab > here you'll get a button called add external jars > clicking to this, will open browser window to select a jar file.
    Regards,
    Sen

Maybe you are looking for

  • HP OfficeJet Pro 8620 Scan to Email Function

    HP OfficeJet Pro 8620 is a great value for all the features it provides. "Scan to Email" was one of the reasons i bought this printer. Even though i can make this fucntion work with my gmail and iCloud emails, i feel very uncomfortable in providing t

  • Photos app do not back up my Photos library into iCloud

    I have just updated to OS x 10.10.3. When I tried to enter the Photo app, I got the message ״There is not enough disk space to migrate your library. It is estimated that you need at least 33GB of additional free space.״ I have a 256 GB SSD hard drive

  • IPhone 3G wont stay connected/powered?

    Hello, I've an iPhone 3G (yes its old want an iphone 4 but can't afford one) I update it to the latest iOS in iTunes last night i have only just updated to iOS 4.2.1 i was running 3.x something however i updated it last night. However since i have up

  • Constant HP printer crashing issues

    Currently if anyone in my dept at my University tries to print a page from the Apple store it immediately crashes our HP 8150 with a 79.01.fe error. I tried saving the page as a PDF, copying and pasting rich text into TextEdit, saving as PS, all stil

  • HelloWorld:  HTMLLoader failed to initialize on MAC OSX

    Hi All... Just Started Playing with AIR. Installed the runtime and the latest jdk on a Mac running OSX 10.6.7. Following the AIR 1.5 HTML Docs, attempted to run the HelloWorld application. I copied and pasted the HelloWorld-app.xml content and HelloW