Access jar's and dll's whithin a single jar file???

Hello everybody!
I am building an application which is dependent on external jar and dll files. I would like to put these external files in my project jar, and in runtime I want to set the path to these files located in my project jar. Is this possible? I have tried this:
structure in my project jar:
-myApp.jar
+META-INF
-myApp
-Main.class
external.jar
external.dll
and in my manifest file:
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.2
Created-By: 1.4.2_01-b06 (Sun Microsystems Inc.)
Main-Class: myApp.Main
Class-Path: /external.jarWhen I try to run my application jar with:
java -jar myApp.jarI get "java.lang.NoClassDefFoundError" .....
i.e. the WM does not find my external jar.
My question now: Is it possible to do things this way? That is to put dependent jars and dlls INSIDE the "running" jar????
Hope someone can help me...
Best regards
TM

You cannot put a JAR inside a JAR - Java won't be able to find the files in the packaged JAR.
What you could do is unpack the myApp.jar and external.jar and include the directory structure inside your own project.jar.
It will not work with a DLL inside the JAR. There's no way around it - the DLL must be a file in the file system, otherwise Windows will not be able to load it (Windows doesn't know what JAR files are, and it can't load a DLL that's inside a JAR file).

Similar Messages

  • Unable to access jar file error !

    hello,
    i have built my netbeans project and obtained the hequalifies.jar file . unfortunately when i'm trying to run this jar file from the prompt command I'mgetting the error: unable to access jar file
    here is the command i'm typing:
    C:\Users\User\Documents\NetBeansProjects\hEqUALIFIES\dist>java -jar " C:\Users\U
    ser\Documents\NetBeansProjects\hEqUALIFIES\dist hequalifies.jar "
    anyone has any clue?
    10x!

    ok i'm gonna make it easier on you.
    i gess i found what is the problem but have no idea how to solve it.
    when i obtained the .jar file i also obtained a README.txt file in which it is written the following phrase:
    ** If a library on the projects classpath also has a Class-Path element*
    specified in the manifest,the content of the Class-Path element has to be on the projects runtime path.
    I'M SORRY BUT I DID NOT UNDERSTAND WHAT IS MEANT BY: what is "the projects runtime path"?
    the content of my manifest is:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: 10.0-b23 (Sun Microsystems Inc.)
    Main-Class: hequalifies.ui.HeQualifies
    Class-Path: lib/PlugIn
    X-COMMENT: Main-Class will be added automatically by build
    I'm having problem with lib/plugin.

  • Error message at start-up Unable to access Jar file

    I am a consumer, not a business...and not an IT professional. I am running Vista and have not installed any new software recently.
    At every start-up, I get a pop-up titled Java Virtual Machine Launcher. The message says "Unable to access jar file". C:\users\user\.jnana.jnana.tsa.
    Any idea how to fix this?
    Thanks in advance.
    Edited by: 794979 on Sep 15, 2010 5:31 AM

    ok i'm gonna make it easier on you.
    i gess i found what is the problem but have no idea how to solve it.
    when i obtained the .jar file i also obtained a README.txt file in which it is written the following phrase:
    ** If a library on the projects classpath also has a Class-Path element*
    specified in the manifest,the content of the Class-Path element has to be on the projects runtime path.
    I'M SORRY BUT I DID NOT UNDERSTAND WHAT IS MEANT BY: what is "the projects runtime path"?
    the content of my manifest is:
    Manifest-Version: 1.0
    Ant-Version: Apache Ant 1.7.1
    Created-By: 10.0-b23 (Sun Microsystems Inc.)
    Main-Class: hequalifies.ui.HeQualifies
    Class-Path: lib/PlugIn
    X-COMMENT: Main-Class will be added automatically by build
    I'm having problem with lib/plugin.

  • Combining 2 files and mapping it to a single destination file

    hi all;
    if i am combining 2 files and mapping it to a single destination file then do we need to define 2 sender communication channels and 1 receiver communication channel

    i have done with the BPM.
    steps
    1 Block with corelation name
    2 Fork with end condition counter not equal 2
    3 fork branch 1 -- receive with corelation and container incrementing count by 1
      fork branch 2 -- receive with corelation and container incrementing count by 1
    4 transformation
    5 send
    i have source file structure during mapping:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
       <ns0:Message1>
          <ns1:SenderData1 xmlns:ns1="http://multimapping.com">
             <Name>AAAA</Name>
          </ns1:SenderData1>
       </ns0:Message1>
       <ns0:Message2>
          <ns1:SenderData2 xmlns:ns1="http://multimapping.com">
             <Name>BBBB</Name>
          </ns1:SenderData2>
       </ns0:Message2>
    </ns0:Messages>
    i breaked the structure in 2 and placed it in different files
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:SenderData1 xmlns:ns0="http://multimapping.com">
       <Name>AAAA</Name>
    </ns0:SenderData1>
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:SenderData2 xmlns:ns0="http://multimapping.com">
       <Name>BBBB</Name>
    </ns0:SenderData2>
    is that all to be done

  • Access jar file from in-memory classes...

    I have some classes that I compile to memory and everything works fine until one class that must access some external jar files. I have been unable to access those jar files from disk after trying every suggestion using URLClassLoader. I even tried someone's example to hack the SystemClassLoader which properly adds the jar file paths, but still they can't be seen. The only way it works is if I put the files in the jdk/jre/lib/ext directory. Then everything works fine. There must be a way to load the jar files in memory as well as the class files so they can be accessible. Has anyone done anything like this? Is it possible? Even though the class files are in memory, why would the jar files not be seen even when they are added to the same URLClassLoader's URL's. Thanks.

    Sorry that wasn't clear. What I mean is that the classes are compiled to byte code directly to memory and no physical .class file is created. Yes, I'm using my own ClassLoader that extends URLClassLoader and I'm setting the parent to ClassLoader.getSystemClassLoader(). I also should mention that I'm doing this inside a Netbeans module that is part of a Netbeans Platform application. I don't know why that should matter though, since I'm trying to do everything in memory without creating the physical files. Thanks.

  • How to access jar files

    Hello,
    I've created a web application using servlets and jsp.
    Under Tomcat/webapps dir, I created my project dir and copied jsp files there, whereas copied all the java and class files under webapps/projectdir/WEB-INF/classes/mypackage. I also created a web.xml file under WEB-INF dir with my servlets mapping. I aslo created a lib dir under WEB-INF and copied jstl.jar and standard.jar in there. So far my application runs fine.
    Now I've to include some jar files that will be providing data from the backend to my servlet. I can't have .class files instead of .jar files, that is the restriction the way the backend files are built.
    Can anyone tell me how to make Tomcat access those jar files.
    Thanks.

    Ok then. I think the page you should read is [Tomcat 5 classloader documentation|http://tomcat.apache.org/tomcat-5.5-doc/class-loader-howto.html], though they simplified the structure in [Tomcat 6|http://tomcat.apache.org/tomcat-6.0-doc/class-loader-howto.html].
    Normally the classpath of a web application is restricted to
    - WEB-INF/classes directory
    - jar files in WEB-INF/lib
    - jar files in the server /lib directory.
    So if you have a common library that is used by multiple web applications, you could give each web-app their own individual copy of that library in WEB-INF/lib, or you could have them all use the same one in the server lib directory. There are pros and cons to both approaches.
    Cheers,
    evnafets

  • Access JAR File while running App with Java Web Start

    Hello guys,
    I want to delpoy my application so that I can run it when I click on the appropriate button in a web page.
    I have a Jar file for all the files that the app needs. No, not all of the files are included.
    Indeed, I use JAR files such jdom.jar or postgres...jar that I must use in within my application.
    How can I access these JAR files knowing that I can't point to files in a JAR file A from within a JAR file B, if the JAR file B contains the JAR file A?
    The main JAR file that I put on the web server can be seen as the JAR file B and the other JAR files must be stored somewhere for the java classes within the main JAR file to have access to them.
    I wonder whether there is another way to structure the project.
    Thanks.

    Hi Andrew.
    I have followed your suggestions and here is what my .jnlp file look like:
    <tt>
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/koedops" href="beta.jnlp">
         <information>
              <title>KOEDOPS</title>
              <vendor>Pr. Fischer</vendor>
              <homepage href="http://localhost:8080/" />
              <description>Downloading koedops with Java Web Start</description>
         </information>
         <resources>
              <j2se version="1.6+" />
              <jar href="beta.jar" main="true"/>
              <jar href="jcalendar-1.3.3.jar" />
              <jar href="jdom.jar" />
              <jar href="postgresql-8.4-701.jdbc4.jar" />
         </resources>
         <application-desc main-class="general.Application" />
    </jnlp>               
    </tt>
    The three other jar-files reside in the same directory as the .jnlp file and the beta.jar file on the tomcat server.
    When I launch the application though nothing happens upon the download. In contrast, if I change the main class to a class file that requires no extra library, it runs perfectly.
    I can't be sure whether the jar-files are successfully accessed.
    Regards.
    Edmond

  • Web server cannot access .jar file?

    Hi all,
    I'm using NetBeans 4.1 IDE with the bundled Tomcat 5.5.7 on Windows XP sp2.
    I have a .jar file which I must make available for the web server (not only for my web app). So I did the following:
    Added a CLASSPATH variable to the user environment (pointing to my .jar file),
    Shutdown Tomcat,
    Restarted the IDE (because it is responsible for launching Tomcat, so Tomcat inherits its environment vairables from the IDE),
    and finally ran my web-app.
    The result: the web app could not find classes from the .jar file.
    However, if I copy the .jar to the server's common/lib directory, everything's ok!
    Why? I'm sure I don't have to put .jars in common/lib in order to make them visible by the server! I've read that adding them to the CLASSPATH is just as good solution... what is going on?

    Tomcat has its own ideas about classpath. In particular it ignores the system classpath, so that each web application can have its own seperate one.
    Jar files should normally live in the /WEB-INF/lib directory of your application.
    If you want to share them across multiple apps, use the /shared/lib directory.
    /common/lib should not normally be used except for database drivers when using tomcats JNDI datasources.
    Cheers,
    evnafets

  • Can I use a select and update statement in a single jsp file?

    I want to update the BUY table everytime I would add a SELL transaction.....I want to minus the stocks that I sold to those that Ive bought before.....
    note: I used a seperate table in BUY and SELL transaction
    After I Have added a transaction, I want to update the buy table. This is my problem, can I used both SELECT and UPDATE statement at the same time in a single jsp file for example like this:
    select * from test, test1;
    update test
    set total_shares=total_shares-Stotal;
    where stock_code=Scode AND name_broker=Sbroker;
    Can i have both of these statements in the same jsp file in oder to update the buy table?
    Or can anyone suggest how can process that update?THANKS!
    --------------------

    Can i have both of these statements in the same jsp file in oder to update the buy table?Yes. But wouldn't it have been easier just to try it?

  • Accessing JAR file

    How i can access a file inside my JAR? Anybody there to help me?

    Touchy subject.
    Look in the [java.util.jar|http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/package-summary.html] package to get ideas. You might also want to check google for "java unpack jar" and use that to read files.

  • Error while accessing jar file at url

    Hi all
    I get following error when I try to access http://192.168.0.100:8090/test/mysql-connector-java-3.0.17-ga-bin.jar
    type Exception report
    message
    description The server encountered an internal error () that prevented it from fulfilling this request.
    exception
    javax.servlet.ServletException: Servlet execution threw an exception
    root cause
    java.lang.NoSuchMethodError: org.apache.naming.resources.ResourceAttributes.getCanonicalPath()Ljava/lang/String;
         org.apache.catalina.servlets.DefaultServlet.checkSendfile(DefaultServlet.java:1521)
         org.apache.catalina.servlets.DefaultServlet.serveResource(DefaultServlet.java:839)
         org.apache.catalina.servlets.DefaultServlet.doGet(DefaultServlet.java:348)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:689)
         javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
    note The full stack trace of the root cause is available in the Apache Tomcat/5.5.12 logs.-------------------
    Could someone help me what is the wrong setting at my system.
    Thanks
    Aamir

              Hi
              Thank you.Is there a way to read a file which is existing in the war file.
              Regards
              Anand Mohan
              "Wenjin Zhang" <[email protected]> wrote:
              >
              >In Weblogic, if your files are archived in a WAR, you cannot get an entry
              >as individual
              >file since it is only bytes in a large archive file. So getRealPath will
              >give
              >you null result. If you only want the path, try to use other getXXXPath,
              >getURL,
              >or getURI method. If you want to read the content, use getResource.
              >
              >
              >"Anand" <[email protected]> wrote:
              >>
              >>Hi
              >>I am having problem while accessing the file located in the server from
              >>a JSP
              >>page. I am not getting the RealPath from a JSP page using getRealPath(request.getServletpath()).
              >>
              >>The same code is working if the jsp placd under defaultwebApp directory
              >>and not
              >>working if i create a war and deploy the same.
              >>
              >>I am using weblogic server 7.0 trail version.I am setting the context
              >>path also.
              >>
              >>Can any help me in this regard.
              >>
              >>Thank And Regards
              >>
              >>Anand Mohan
              >
              

  • Applet tag accessing JAR file

    hi,
    I hope this is not a multi-post, I've searched high and low and I could not find an exact solution to my question...
    How can I load an applet in a browser using an applet tag? My main class is com.my.applet.MainClass.class and the its in a JAR. The jar is in ProjectName/WebContent/WEB-INF/lib/MyJar.jar (a Dynamic Web Project).
    Thx in advance

    i guess there is no solution for this one... i placed it in a resource folder instead... thx everyone...

  • Console not display when run jar file

    i run jar file with command javaw -jar test.jar or double click on jar file, it's console app, it just run well but console not display, can i made console display and when i close console, it's stop jar file too?
    thanks

    i got it, javaw = no console window, i tried java command and i got error: can not access jar file?

  • Accessing a images and a external library packaged in a jar

    I am trying to include a library (abc.jar) in another jar file (def.jar). The classes in def.jar import functionality from the abc.jar file. May I know if it is possible and if it is possible, how do I achieve it?
    I need to access images in a jar file (ghi.jar) from classes which are in the same jar file. In addition, I specified the classpath to include an additional library (tgf.jar) located external to ghi.jar itself. This had caused the images to be inaccessible by my java classes. I had used the getResource() method from Class to load the images. Is there any way to solve this problem?
    Regards,
    Clivant

    You cannot access a resource inside a jar which is inside another jar.
    If you need to access a resource which is in your class path use
    getClass().getClassLoader().getResourceAsInputStream(name);

  • Storing a JAR file in a database and then accessing it

    Is it possible to store a JAR file in a database and then access it like a normal jar that is on your classpath?
    I'm sure this is not possible but can you specify an XML schema in an XML document where the XML schema file lives in the jar but the xml file doesn't?
    Cheers.

    Hello,
    Is it possible to store a JAR file in a database and
    then access it like a normal jar that is on your
    classpath?
    Is it possible? Well, yeah, anything's possible ;-)
    Can you do it without a custom ClassLoader? No.
    I'm sure this is not possible but can you specify an
    XML schema in an XML document where the XML schema
    file lives in the jar but the xml file doesn't?See above. ;-)
    -Ron

Maybe you are looking for

  • Internet sharing from my macbook pro to my iPhone 5

    I have changed the MAC address on my macbook pro. This was successful and i continue to use the internet using the internal router also to provide wifi internet to my iPhone. However, since changing the MAC address, i am prompted to put my password i

  • HT5639 windows 7 starts with an error report

    hi,can anyone help me to get windows back on to my imac.,i have a problem with uploading windows,it starts with an error report saying there is a problem and gives me two options the 1st it tries to repair the problem and then tells me it cant repair

  • Error message "Ovi store is currently not availabl...

    Hi all ! This is my first post and I hope you guys can help me... I am trying to install SKYPE in my N95 (running V35.2.001 13-10-09, RM160) and when I try to open the link sent from the OVI Store via SMS directly to my phone I get the above mentione

  • Can I buy a microsim?

    Does anyone know if I already have an account with AT&T, and buy an iPhone 4 on eBay etc. can I buy a microsim with my same number on it just by walking in the store?

  • 5.5 trial: zero denominator error message

    First, from within PP 5.5 trial version, I tried to dynamically link an XDCAM clip between with AE 5.5 trial version.  The footage in AE was interpretted as audio only, when it is 1080p 25. ) I have a simple MP4 comp in AE5. The same interpretation h