How to put native methods in jar file

Hi.I have an executable jar file(test.jar) that makes use of other jar files and native methods. For example, test.jar uses Jnpout32.dll. . test.jar , the other jar files and the native methods are all in the same directory. When I created test.jar I wrote a manifest file which specifies the class path of the other jar files and the native methods as follows and provided it as an option in the jar cfmev command.
Class Path: jdbc.jar Jnpout32reg.dll  //content of manifest.txt  file that I provided to the jar command
//carriage return I then run the command java -jar test.jar to run the file.
All I am seeing is the following error message
Exception in thread "AWT EventQueue-o
"Java.lang.NoClassDefFoundError.
gnu/io/SerialPortEventListner"
{code}
Any ideas? thanks in advance!
Edited by: Nostalgia on May 22, 2009 8:05 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

You seem to be confusing Java's classpath with your os's path. The classpath only applies to Java classes. See if this discussion helps:
http://www.inonit.com/cygwin/jni/helloWorld/load.html

Similar Messages

  • How to put Chinese character in jar file by java.util.jar.Manifest?

    Now I want to develop a simple package tool which can modify some property in manifest.mf of jar files,but the Manifest class's putValue method only can correctly save English character.why?
    And how can I put Chinese character?
    the code is:
    Attributes ab = mf.getMainAttributes();
    ab.putValue("agent-Name", agent);

    Attribute values can contain any character and it will be UTF-8 encoded when written to the manifest, according to Javadoc.
    What makes you think that this mechanism fails? What do you see instead of the Chinese character? And what tool/editor/program you use to see it? I did not try myself, but according to the Javadoc there should be no problem.

  • How to call the methods of JAR file into webDynpro Environment

    Hi All ,
             I have a requirement to call the methods of a JAR file into
             WebDynpro Environment. can anybody suggest me How this can be achieved. I Have a JAR file named FastTrack.API
    which contains few methods and i want these methods to be accessable into WebDynpro as other methods.
    Plz Somebody help me to sort this out.
    Regards,
    Deepak.

    Deepak,
    Please follow these 2 steps:
    1. Add jar into webdynpro project
            Right Click on ur project -> Select properties -> Java Buil path -> Choose Libraries Tab -> Add External Jars -> add the file from ur computer
    2. Use the jar
          write the import statement in your webdynpro code to utilize the properties of added jar.
    Thanks & Regards,
    Ram

  • How to create and use library JAR files with command-line tools?

    Development Tools -> General Questions:
    I am trying to figure out how to put utility classes into JAR files and then compile and run applications against those JAR files using the command-line javac, jar, and java tools. I am using jdk1.7.0_17 on Debian GNU/Linux 6.0.7.
    I have posted a simple example with one utility class, one console application class, and a Makefile:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130520-2134.tar.gz
    Here is a console session:
    2013-05-20 21:39:01 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-20 21:39:12 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/hello/HelloConsole.java
    package com.example.hello;
    import static com.example.util.Hello.hello;
    public class HelloConsole {
        public static void main(String [] args) {
         hello("world!");
    2013-05-20 21:39:21 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -f hello
    find . -name '*.class' -delete
    javac src/com/example/util/Hello.java
    javac -cp src src/com/example/hello/HelloConsole.java
    echo "java -cp src com.example.hello.HelloConsole" > hello
    chmod +x hello
    2013-05-20 21:39:28 dpchrist@desktop ~/sandbox/java/jar
    $ ./hello
    hello, world!I believe I am looking for:
    1. Command-line invocation of "jar" to put the utility class bytecode file (Hello.class) into a JAR?
    2. Command-line invocation of "javac" to compile the application (HelloConsole.java) against the JAR file?
    3. Command-line invocation of "java" to run the application (HelloConsole.class) against the JAR file?
    I already know how t compile the utility class file.
    Any suggestions?
    TIA,
    David

    I finally figured it out:
    1. All name spaces must match -- identifiers, packages, file system, JAR contents, etc..
    2. Tools must be invoked from specific working directories with specific option arguments, all according to the project name space.
    My key discovery was that if the code says
    import com.example.util.Hello;then the JAR must contain
    com/example/util/Hello.classand I must invoke the compiler and interpreter with an -classpath argument that is the full path to the JAR file
    -classpath ext/com/example/util.jarThe code is here:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130525-1301.tar.gz
    Here is a console session that demonstrates building and running the code two ways:
    1. Compiling the utility class into bytecode, compiling the application class against the utility bytecode, and running the application bytecode against the utility bytecode.
    2. Putting the (previously compiled) utility bytecode into a JAR and running the application bytecode against the JAR. (Note that recompiling the application against the JAR was unnecessary.)
    (If you don't know Make, understand that the working directory is reset to the initial working directory prior to each and every command issued by Make):
    2013-05-25 14:02:47 dpchrist@desktop ~/sandbox/java/jar
    $ cat apps/com/example/hello/Console.java
    package com.example.hello;
    import com.example.util.Hello;
    public class Console {
        public static void main(String [] args) {
         Hello.hello("world!");
    2013-05-25 14:02:55 dpchrist@desktop ~/sandbox/java/jar
    $ cat libs/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-25 14:03:03 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -rf bin ext obj
    mkdir obj
    cd libs; javac -d ../obj com/example/util/Hello.java
    mkdir bin
    cd apps; javac -d ../bin -cp ../obj com/example/hello/Console.java
    cd bin; java -cp .:../obj com.example.hello.Console
    hello, world!
    mkdir -p ext/com/example
    cd obj; jar cvf ../ext/com/example/util.jar com/example/util/Hello.class
    added manifest
    adding: com/example/util/Hello.class(in = 566) (out= 357)(deflated 36%)
    cd bin; java -cp .:../ext/com/example/util.jar com.example.hello.Console
    hello, world!
    2013-05-25 14:03:11 dpchrist@desktop ~/sandbox/java/jar
    $ tree -I CVS .
    |-- Makefile
    |-- apps
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.java
    |-- bin
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.class
    |-- ext
    |   `-- com
    |       `-- example
    |           `-- util.jar
    |-- libs
    |   `-- com
    |       `-- example
    |           `-- util
    |               `-- Hello.java
    `-- obj
        `-- com
            `-- example
                `-- util
                    `-- Hello.class
    19 directories, 6 filesHTH,
    David

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

  • How can I get a single jar file with NetBeans?

    How can I get a single jar file with NetBeans?
    When I create the project I get these files:
    dist/lib/libreria1.jar
    dist/lib/libreria2.jar
    dist/software.jar
    The libraries that have been imported to create the project are in separate folders:
    libreria1/libreria1.jar
    libreria2/libreria2.jar
    libreria1, libreria2, dist folders are all located inside the project folder.
    I added the following code to the build.xml:
    <target name="-post-jar">
    <jar jarfile="dist/software.jar">
    <zipfileset src="${dist.jar}" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria1.jar" excludes="META-INF/*" />
    <zipfileset src="dist/lib/libreria2.jar" excludes="META-INF/*" />
    <manifest>
    <attribute name="Main-Class" value="pacco.classeprincipale"/>
    </manifest>
    </jar>
    </target>
    Of course there is also the project folder:
    src/pacco/classeprincipale.form
    src/pacco/classeprincipale.java
    Can you tell me what is wrong? The error message I get is as follows:
    C:...\build.xml:75: Problem creating jar: archive is not a ZIP archive BUILD FAILED (total time: 2 seconds)

    This is not a NetBeans forum, it is a JDeveloper forum. You might want to try http://forums.netbeans.org/. I also saw your other question - try looking in the New to Java forum: New To Java

  • How to handle 2 or more .jar files with an applet

    Hey out there
    I have created an ftpClient application that uses "jakarta ftpClient". It works fine as an JFrame application � But when I converted the Application into an JApplet I get the following Exception:
    java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
    I have bundled the main application into a .jar file (Application,jar). But I don't know how to handle the 2 jakarta .jar files with my JApplet??
    I Tried to append the 2 jakarta .jar files to the Application,jar with the following code:
    jar cvf Application.jar 1.class 2.class�. commons-net-1.4.1.jar jakarta-oro-2.0.8.jar
    But with the same result / Exception (I have signed the Jar file!)
    Can anyone help me

    Hi i have a question with your application can you down- or upload more files at the same time? Because i'm having problems with my ftp application.
    Here is the link with my problem maybe you can help me. I will be very pleased when you can help me.
    http://forum.java.sun.com/thread.jspa?threadID=5162042&tstart=0
    Thx
    Satanduvel

  • How to use native method

    how to use native methods

    ----- BEGIN CANNED RESPONSE -----
    Download and read Sheng Liang's book, ftp://ftp.javasoft.com/books/specs/jni.pdf
    Read the JNI specs on java.sun.com site ( http://java.sun.com/j2se/1.4.2/docs/guide/jni/index.html )
    Beware with the JNI tutorial on the java.sun.com site - it is slightly outdated, and the samples need modifications to compile
    ----- END CANNED RESPONSE -----

  • Where to put common classes and jar files

    hi,
    i want to put some classes and jar files in a common folder so that it can be accessed by other applications is there any way doing that.In tomcat server they have common and shared directories once any classes are into that folder they are being accessed easily ,but i am having problems with sun one .
    Regards
    Ameem Sami

    Did you find a solution for this? I'm having the same problem.
    Thanks,
    Tony

  • How do I deploy an external JAR file

    Hello,
    How do I deploy an external JAR file?
    I am grateful for every hint.

    Hi Manuel,
      If you read my blog mentioned in the beginning of the thread, you will note that such solution is not supported in our engine due to number of reasons.
      Please, read the blog and use application library shared among these two applications. You will achieve the same effect. Please note that the using application will need run and deploy-time dependencies to the shared library.
      You should not add files to any of the folders manually or manipulate engine's classpath in such situations.
    Best Regards,
    Georgi

  • How to include externel library in JAR file?

    Hi all =)
    I have a program that uses an external library (in a JAR file) I would like to compile my program as a JAR and have it include the external library that it needs to run, so that the external library would not need to be on the computer running my program. How can I do this?
    Thanks =)
    Koneko349
    Message was edited by:
    Koneko349

    Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
    C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
    I do not get this error when I run and use my program from within the IDE.
    The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path=""/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry kind="lib" path="D:/poi.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>I would really like to get this working and I'm very confused XP

  • How to retrieve resources from a jar file ?

    Hello,
    Currently, I have application classes in a jar file, and all other resources (pictures, properties, and so forth..) in my windows folder. I do not have any problem for using them such way. For example to set an icon to a JFrame I have coded :
    f.setIconImage("mypicture.jpg");To make installation easier, I'd like to put my picture into the jar file with the classes. Is it possible ? if so, how should I modify my code to make things work ? Should I specify a special path ?
    Thanks for all
    Gege

    Thanks a lot, I'm going to try both ways.What both ways? Both replies are about the same thing -- using the classpath to find resources.
    The question now is what about if there is the same file
    name in the jar file and also in the directory ? Is
    there a search hierarchy ?It will find the first one it encounters in the classpath. You shouldn't have 2 resources with the same name in the classpath -- that's just like having two classes with the same package and class name.

  • How to deploy a bunch of jar files

    All,
    I am just after downloading iPlanet App Server and have been trying to find information on how to deploy a bunch of packaged jar files.
    Basically if anyone can help it would be great, my problem is that I have a number of jar files that make up an application that I developed a while ago, I was using the 9ias app server but have decided to try out the iPlanet app server. Now what I need to know is how do I put the jar files onto the server for deployment???I had a look at the deployment tool but it would not allow me to deploy any of my jar files????Also a couple of the jar files I want to put into the class path, so where is that?
    Any help would be fantastic
    Thanks in advance
    J

    the first thing, that I suppose you know, is that iPlanet needs an extra xml file. If your jars have this exta xml file , the only thing is to use the iasdeploy command line to deploy your jars fles

  • How to Provide Native Methods in an Executable?

    Hey there,
    I'm writing a native Java launcher as a replacement for java.exe (or eclipse.exe). So far I'm only on Windows NT x64. Things work pretty well: My native executable launches the JVM using the Invocation API and calls a static `main' method.
    Now I thought it was a good idea if my executable could provide the implementations of a few native methods so the `jvm.dll' can communicate with the executable that it was loaded by. This would free me from having to locate and load a shared library at runtime. I expected this to "just work," but alas, it didn't. Providing a simple native method such as
    JNIEXPORT jboolean JNICALL
    Java_com_phrood_kourou_Kourou_available0(JNIEnv* env, jclass cls) {
    return JNI_TRUE;
    in the executable and calling it from Java through JNI, I get an `UnsatisfiedLinkError'. Why is that so? Both the executable and the DLL live in the same process, so shouldn't the C function be found without further concern?
    Then I came up with the somewhat experimental idea and just loaded the EXE file from Java by `System.load(pathToExe)'. I never expected this to work, but---it did!
    That's good news, of course. Only I'm afraid that's a lot more memory-consuming than it needs to be. My EXE file has some 200 KB and counting, and I only need I a handful of small native-method implementations. I could write a DLL, of course, but I'd like to do without an extra file and an extra project to set up and maintain.
    So, my question is: Why do I have to load the EXE into the same process a second time? Is there a more elegant solution?
    Regards,
    -- Phil

    It doesn't work anyway. Although I can load my EXE as a DLL, the newly-loaded image has its own address space, so I cannot use that to call back the EXE.
    I think I can acomplish what I need without a DLL altogether. Hopefully.
    I want the usage of my executable to be as simple as using `java.exe'. Clients should just write a configuration file, rename and start or double-click the EXE and that's it. An MSI would be pointless here, since the usage of the launcher is completely generic.
    More importantly, maintaining cross-platforms C++ projects with Eclipse CDT is possible but a bit of a hassle. I already have two projects: one for the EXE and one for the Java companion Jar. Creating a new DLL project would require me to maintain 3 Eclipse build configurations for Windows, Linux, and Mac; and even another three should I support the x86 architecture. I'd be happy if I could do without.
    What strikes me is that you folks try to teach me what I should do or not do, even call my problem a "nonproblem," rather than just help me out and try to answer my questions. None of the answers here were helpful to me, but I think I figured it out.
    Nonetheless, thanks for taking the time to read and answer.

  • How To Load Sound From Inside jar File?

    Hello There
    i've made a jar file that contains Images&Pictures But I Can't Use Them
    So I Used For Loading Images
      URL url = this.getClass().getResource("image.jpg");
             setIconImage(new ImageIcon(url).getImage());and for loading sound when i use
      URL url = this.getClass().getResource("Bond2.wav");         
           AudioInputStream stream = AudioSystem.getAudioInputStream(new File(url));there's an error That The file Constructor doesn't take url
    how can i fix it?

    First_knight wrote:
    and for loading sound when i use
      URL url = this.getClass().getResource("Bond2.wav");         
    AudioInputStream stream = AudioSystem.getAudioInputStream(new File(url));there's an error That The file Constructor doesn't take url
    how can i fix it?Remove the "new File()". There is a getAudioInputStream() method that takes a URL.
    AudioInputStream in = AudioSystem.getAudioInputStream(url);

Maybe you are looking for

  • How to find out the table column that is required for index

    hi all, i want to the column required for index in one schema. what are the ways to achieve the same.

  • Lose AE connected printer on MacBook when G4 goes to sleep

    I have a HP PSC750 connected to my AE, which I set-up on my G4 desktop. Everything works fine until the G4 goes to sleep. When it goes to sleep I lose the printer availability on my MacBook.

  • JLayeredPane with JScrollPane inside

    Hi all, I am making an applet with a fairly complex gui. The main part is a content window that has a jpanel with another jpanel and a jscrollpane inside, each of which have a bunch of components. From there I wanted to add a help window that popped

  • Aperture keeps crashing when opened

    Hello Everytime I open aperture for past few months it keeps on crashing. Even stopped time machine working for a while. I have repaired the library, looked at the files and cannot work out which ones would b bad. Occured just after upload a large am

  • Invoice generation issue in Internal Sales Order Cycle

    Dear All, I have 2 operating unit under one legal entity. I am doing internal sales order cycle between these two operating units. Since our requirement should do credit check for all the sale order, we require Receivable invoice and Payable invoice