Java application - build JAR file & include JCO library

Hello everyone,
I have a problem with my Java application that <i>connects to SAP system using JCO </i>library <b>(sapjco.jar)</b>.
I would like to create a JAR file from my Java application but when I run the JAR file that I created I get an error that <b>NoClassDefinitionFoundError com/sap/mw/jco/JCO at [...]</b>
That means that the JCO and associated DLL files <b>(sapjco.jar, librfc32.dll and sapjcorfc.dll)</b> were <u>not</u> included/packed in my JAR file.
<b>-- How can I include the JCO lib in JAR file?
-- If there is a problem with the DLL files, how can I include the JCO lib externally (dynamicly read the JCO whenever my JAR in run)?</b>
I am using Eclipse 3.2 and Export to JAR option when I click right button on Project.
THANKS IN ADVANCE FOR HELP!!!

Hi,
The problem is that you don't have defined the libraries in the Manifest file of your jar-file. So the jar doesn't know what to use at runtime.
Add following entry to the MANIFEST.MF file:
Class-Path:/<lib_folder>/<lib1_name>.jar; /<lib_folder>/<lib2_name>.jar and so on.
Regards,
Daniel

Similar Messages

  • Java Application as jar File cannot connect to SAP via JCO

    Hey guys,
    I wrote a test class to play a little with the java connector. Everything worked fine.
    Now I want to pack my java class and the JCO classes in one jar file. I have written a manifest file with the Main-Class statement and after I start the jar file I got following exception:
    Exception in thread "main" java.lang.ExceptionInInitializerError: JCO.classIniti
    alize(): Could not load middleware layer 'com.sap.mw.jco.rfc.MiddlewareRFC'
    JCO.nativeInit(): Could not initialize dynamic link library sapjcorfc [no sapjco
    rfc in java.library.path]. java.library.path [C:\WINDOWS\system32;.;C:\WINDOWS\S
    ystem32;C:\WINDOWS;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;c:\Ja
    vaConnector\sapjco.jar;C:\j2sdk1.4.2_12\bin;]
            at com.sap.mw.jco.JCO.<clinit>(JCO.java:776)
            at de.lymez.sti.SAPAufruf.getDocnr(SAPAufruf.java:26)
            at de.lymez.sti.Aufruf.main(Aufruf.java:12)
    Can anyone help me? I don't think that I forget something during the JCO installation, because my class file worked fine and give me the correct values out of the SAP System.
    Best regards,
    Timo

    Thanks Vladimir,
    but I followed the Tutorial and copied every dll in the wright folder and set the pathes. In one of the threads someone told about a tool named dependency walker. I used this with the sapjcorfc.dll and the tool answered that the DRVADODB.DLL is not found. Can anyone send me this dll? And why worked everything fine, when I use the class? I only have problems when I use one jar file!
    Thanks for any help!!
    Regards,
    Timo

  • Images not getting Loaded while running Java Application through jar file

    Hello Friends,
    I have a problem while starting my application.I have written my application using pure java.There is no JSP or anything just pure swings.Mine is a standalone appplication.So i used to run it using a batch file.And when i used to start my application it used to not show me the images.so what i did was i mentioned the starting directory in the properties of the batch file (ie in the start in column field).But that was when i was using weblogic server.And i have lot of people working on the same application.so i used ZAC publisher in weblogic and along with that i used to publish the batch file also.so the users dint have any problem.But now what is my problem is i m trying to use JAVA Webstart instead of weblogic ZAC.Now in webstart what happens is that i have to run the appliaction thru jar file.so where do i mention the class path so that the images get loaded.As of now the imaes are not getting loaded.i feel this is a class path problem.but where do i mention it that is my problem.It would be really helpfule if someone could help me out.
    thanx and regards,
    [email protected]

    try out this
    ImageIcon img1=new ImageIcon(this.getClass().getResource(imagename));
    for exmaple
    Imageicon img1=new ImageIcon(this.getClass().getResource("name1.jpg"));
    dont 4get to include the image files in the jar file

  • Java application to jar file

    I use eclipse and i have a java program which run without any problem,
    but when I export this program to jar file(export->java->jar file)
    I get the jar file and when I run this jar file ,it run for few seconds then it stop to run,despite in eclipse it run .
    I don't know what is the problem

    netcom_ wrote:
    I found the error;I have a file.txt under the bin of the project,but when I export the project this file
    don't appear so when I run the jar it doesn't find the file.this file is neccessery for the project.
    I will read the content of this file,So I think after exporting the project I make it with the jarfile and I use this code to read the file.
         String lin= is.read(buffer);
    Huh?!? Since InputStream.read(byte[]) returns an int, I do not understand how that compiles, let alone runs.
    But any way you cut it, that I/O code was utter rubbish.
    but also it doesn't find the file.When reporting problems, please [copy/paste any error messages|http://pscode.org/javafaq.html#exact] you are getting.

  • IO Error while deploying application client jar file ???????

    Hi,
    In my .ear file, one application-client jar(which contains all helper classes which are used in whole application) file is there. While deploying .ear file, all ejb are getting deployed well, while deploying application client jar file(Global.jar file here) it is giving the following message:
    IO Error deploying Global.jar: D:\oracle9ias\oc4j_extended\j2ee\home\applications\trainiumear\Global.jar
    Here is application-client.xml of Global.jar file:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE application PUBLIC '-//Sun Microsystems, Inc.//DTD J2EE Application 1.2//EN' 'http://java.sun.com/j2ee/dtds/application-client_1_2.dtd'>
    <application-client>
    <display-name>TrainiumClientApp</display-name>
    <description>Application description</description>
    </application-client>
    My Environment: Oracle9iAS (9.0.3.0.0), Windows-NT
    Please let me know Why i am getting 'IO Error' , where i may done wrong ?
    Thanks in Advance
    Srinivas

    Srinivas,
    Before we continue, PLEASE tell me if you've looked through the available
    documentation, code samples, "how-to" documents, etc., for OC4J. It
    seems to me that you're mixing things up a bit. I use the "deploy"
    command to deploy my EARs, example (partial):
    java -jar admin.jar ormi://<host> admin <password> -deploy ...
    And my EAR file is not in the "application-deployments" directory
    when I issue that command.
    Perhaps you could also show me the contents of your "application.xml"
    file for this application you are having trouble with.
    But I repeat, please tell me if you have already looked at the
    available documents regarding OC4J!
    Thanks,
    Avi.

  • Please help: Example how to peploy application from jar file step by step

    Please help: Example how to peploy application from jar file step by step.
    All help appreciated
    Mike

    Thanks I will try these links
    Mike
    "Slava Imeshev" <[email protected]> wrote:
    Hi Mike,
    These links could be useful:
    http://e-docs.bea.com/wls/docs61////adminguide/appman.html
    http://e-docs.bea.com/wls/docs61////quickstart/quick_start.html
    http://e-docs.bea.com/wls/docs61//////ConsoleHelp/application.html
    http://e-docs.bea.com/wls/docs61///programming/environment.html
    Regards,
    Slava Imeshev
    "Mike" <[email protected]> wrote in message
    news:3ca0e94c$[email protected]..
    Please help: Example how to peploy application from jar file step bystep.
    All help appreciated
    Mike

  • How to install a Application in *.jar file format?

    How to install a Application in *.jar file format?
    I have taken the *.jar file into the device into media folder. but device is not recognizing the file format
    could some one plz provide some suggestion to proceed with this?
    Thanks
    Mohamed Javeed

    I'm having the same problem.  I've put .jar into the 'system' folder but that doesn't seem to make the program work neverless see it on my device.  Help.

  • Where is the jar file includes ejb3.0 interface

    I just start using ejb 3.0, when i create a stateless session bean, i can not find the Stateless interface when import javax.ejb.Stateless. Appreciated if someone can let me which jar file includes those interface (like javax.ejb.Remove, javax.ejb.Stateful, etc.) and where to download?

    Hi,
    check jdeveloper_home\jdeveloper_10133_<version>\jlib\identitystore.jar
    Frank

  • How to include JAR file in NetBean library?

    i have downloaded JavaMail jar file and now i want to include this file into NetBean library. pls help me out.

    You can add the jar file to Netbeans as an external library by choosing 'Tools' on the menu bar and then selecting 'Library Manager'. In there you can give it a name and the path to the jar file. Once it is setup, if you go to your project properties, and click the 'Libraries' option on the left you will be able to add it. Select 'Add Library' and choose the one that you just created, it will now be part of your project.
    Alternatively, if you don't want to set it up as a library in Netbaeans, go straight to the project properties, select 'Libraries' and then select the 'Add Jar/Folder' option, now you can navigate to your jar file and add it to your project.
    For other info about JavaMail: http://java.sun.com/products/javamail/FAQ.html#install

  • Difference between running a java application as jar or via batch file?Hi,

    Hi,
    I'm facing some strange differences in the behavior of my application , only caused by different methods to execute the application . So I have know the potential difference between these methods to locate the error.
    1) running my application it with java -jar (via batch-file or command-prompt) or in eclipse works fine
    2) executing the jar by double click causes problems.
    The difference I know are that you can easily pass arguments to jvm, when using the jar.Maybe there is a differences in thread scheduling, but I'm not sure about that.
    Can anyone tell me, the differences between these to methods of execution?
    Thanks a lot in advance.
    Greetings Michael

    Hi,
    to get a clue I have redirected the System.err and System.out to a TextArea
    (see code below) and suddenly the error was gone. So according to the behavior that it had worked before in the ide and via batch file where the System stream can do unlimited writing. I think it is obvious, that something goes wrong with streams of System.
    Does anyone knows what happens to messages which are send to the default streams, when running the app as jar? I normally would assume that they would point to /dev/null or something else, but as I have experienced it seems that they are blocking after a certain amount, which prevented my app from working. (By the way invoking it with javaw has the same effect.)
    This goes a little bit off topic, perhaps I should post a new thread.
    But this is a huge difference between java and and javaw (jar), I wasn't aware of i t until now.
    Hope someone can explain me how javaw handles System.err and System.out.
    Thanks for your participation.
    Greetings Michael
    @SuppressWarnings("unused")
         private static void debug(){
              /* Debug Jar-File if no console exists */
              final JTextArea ta = new JTextArea(25, 80);
              ta.setWrapStyleWord(true);
              final JScrollPane jscp = new JScrollPane(ta);     
              class TextAreaPrintStream extends PrintStream {
                   private JTextArea consoleTextArea;
                   TextAreaPrintStream(JTextArea consoleTextArea, OutputStream out) {
                        super(out);
                        this.consoleTextArea = consoleTextArea;
                   /* (non-Javadoc)
                    * @see java.io.PrintStream#println(java.lang.String)
                   @Override
                   public void println(String x) {
                        this.consoleTextArea.append(x +'\n');
                   /* (non-Javadoc)
                    * @see java.io.PrintStream#print(java.lang.String)
                   @Override
                   public void print(String s) {
                        this.consoleTextArea.append(s);
              TextAreaPrintStream out = new TextAreaPrintStream(ta, System.out);
              TextAreaPrintStream err = new TextAreaPrintStream(ta, System.err);
              System.setOut(out);
              System.setErr(err);
              JDialog dialog = new JDialog( (Frame) null, "Log" , false);
              dialog.setContentPane(jscp);
              dialog.setSize(dialog.getPreferredSize());
              dialog.setVisible(true);
              System.err.println("Test Error");
         Used proposed solution from sn.schulz :
    http://forum.java.sun.com/thread.jspa?forumID=257&threadID=213477

  • How to create a jar file as a library in java?

    Let me put it simple: rb.java is already put under /home/jiane/rb/rb.java;
    the tar file rb.tar being located under /mylib/rbcore/, the test client is put under /home/jiane/test.java. now rb.java looks like
    //// rb.java
    import java.until.*;
    public class rb {
    %>jar cvf /mylib/rbcore/rb.jar /home/jiane/rb.class
    test.java as below
    //// test.java
    import mylib.rbcore.*;
    import java.until.*;
    class test {
    %>export CLASSPATH="/mylib/rbcore/rb.jar;."
    %>javac test.java
    %>test.java:1 package mylib.rbcore does not exist
    so, how to make adjustment to rb.java & test.java so that I can make use of jar file rb.jar. please shows the steps to do. thanks a lot.

    import mylib.rbcore.*;This assumes the package mylib.rbcore and imports all its classes.
    But the source of the class does contain package statement, so the class is in the default package.

  • Problem in run the Java ME application using jar file

    Hi all,
    I am using Eclipse 3.3 with CLDC and MIDP, I add external jar file for my application. The jar contains MIDlet and some classes. I create a class (not MIDlet) that have same package name and Class as in jar file.
    Say for example the jar file have com.Displaytext and My new project have com.Displaytext.
    The problem is my application takes the class file in external jar but my intent is the application class file needs to work.
    I welcome your answers.
    Edited by: chals on Aug 23, 2008 12:24 PM
    Edited by: chals on Aug 23, 2008 12:25 PM
    Edited by: chals on Aug 23, 2008 12:37 PM

    For class loading inside or outside of JAR files I use this code:
    void loadClass (String className) {
        String prefix = "de.test.";
        String postfix = ""; // use this if your classes have a name pattern
        Object o = Class.forName(prefix + className + postfix).newInstance();
    void loadClass (String className, Class[] paramClasses, Object[] params) {
        String prefix = "de.test.";
        String postfix = ""; // use this if your classes have a name pattern
        Object o = Class.forName(prefix + className + postfix).getConstructor(paramsClasses).newInstance(params);
    }

  • Creating jar file including 2 another jar files

    hi
    My project has java files, properties files,batch files as well as two jar files,mail.jar & activation.jar(for importing packages).
    I have to include these jar files while setting environment variables.
    Now i want to make "MyPrj.jar" file for myproject ,can anyone pls help me how to include these all files into a single jar file. and how to make setup file
    I have tried to extract out .class files of mail.jar & activation.jar & i ve created MyPrj.jar by including all class files(including class files of mail.jar & activation.jar) but manifest file(headers) are not added to MyPrj.jar.
    i have also tried to give mail.jar & activation.jar in Class-Path of menifest file, but it is also not working.
    Pls Help
    Thanks a lot

    [http://sourceforge.net/projects/one-jar]
    "One-JAR(TM) is a simple solution to a vexing problem in Java: how to distribute an application as a single jar-file, when it depends on multiple other jar-files. One-JAR uses a custom classloader to discover library jar files inside the main jar. "

  • How to compile jar file including all dependencies ?

    Hi all,
    I have an application with more than 50 classes that use third party libraries.
    I would like to compact everything in just one single jar file BUT just the classes I need, not the whole external libraries.
    Archive builder from JBuilder works pretty fine, but I need a command line tool to integrate this into an automatic compilation process from a bigger project.
    What can I use ?
    Thanks a lot!

    Yes, I can live with it but, I cannot
    believe
    that there is no any command line tool for doingwhat
    Archive Builder from Borland does !!I'd bet a year's salary that Archive Builder isn't
    foolproof anyway. When you consider classes may be
    instantiated dynamically thru reflection and so
    forth, there's no way any tool can really tell with
    100% certainty what all the dependencies are.But apart from dynamic class loading? I can manage dynamical loaded classes manually, but would be really helpful to have an automatic tool for including all 'static' dependecies.
    This is a common task in other programming languages. How to do this using standard (free?) java tools?

  • NOT WORKING: Putting a jar file requiring native library in bootclasspath

    Hi,
    I put my own jar file into the bootclasspath like this:
    java -Xbootclasspath/p:myboot.jar TestClass
    Some classes in the jar require a native library. For JVM 1.3 on Solaris, I put the native library in $JAVA_HOME/jre/lib/sparc and everything works just fine.
    However, when I try the same thing on JVM1.4, I got the following error when my class containing the native methods is called:
    Failed to load the native library: myboot_native
    java.lang.UnsatisfiedLinkError: no myboot_native in java.library.path
    I tried to put that native library in several different directories in jre/lib but still had no luck.
    Is there anybody know the solution? Does JVM1.4 allow me to put a custom jar file that requires a native library in the bootclasspath?
    Regards,
    Eman

    Well is your file in a directory included in the java.library.path environement variable. I use java on windows but I have to add the directory where my native library is to the path variable (not classpath) in order to avoid the error you get.

Maybe you are looking for