Accessing Jar

Hello, I have a problem. I know how to search for a file and delete/rename it. Now I'd like to search for a .class file within a given JAR file and to substitute the .class in the Java Archive with another .class file. Any idea?
Thanks in advance

Well, thanks everyone for the support.
I would like to avoid the thing with the Runtime, but it was similar to what I come up with myself. Obviously using the util.jar packages would be much more elegant, but I guess I'd better cut it short, and work on the faster solution for now, thinking to the best solution for the future!

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.

  • Weird classpath issue in EAR.Some classes can access jars that others cant!

    Hi,
    I'm experiencing a very frustrating problem that's proving to be a bit of a show stopper for me. I would really appreciate some help...
    I have an EAR deployed successfully on Sun Appserver 8 which passes the tests from the sun EAR verifier tool. The ear contains a jar file that I built which has a stateless session bean, home, remote interfaces and rmi stubs, deployment descriptors, as well as some utility classes. The EAR also contains some third-party jars such as Hibernate, Log4-j, apache-commons etc etc. The jar I built has in it's manifest file, the classpath information to reference the other jars in the ear.
    The problem I am having is that one of the classes in a third-party jar (hibernate3.jar) cannot see a class in another of the third party jars (log4j-1.2.8.jar) and as a result is throwing a NoClassDefFoundError for org/apache/log4j/Layout while trying to initialise - the two jars are at the root of the EAR.
    Furthermore, my utility classes can access and use Log4j classes without any problem and logging command from those classes is output successfully to the server console. However, my session bean, which is packaged in the same jar as the utility classes, fails to log anything even though it uses exactly the same logger and log configuration as the utility classses.
    I have tried adding classpath information to the manifest of the EAR so that the third-party jars can pick it up but this makes no difference. Also, according to the EAR verifier tool, you are not allowed to put any classpath information in the EAR manifest.
    I have also tried deploying this in weblogic but am experiencing the same problem.
    If anyone can offer any advice or solutions I would greatly appreciate it.
    :)

    what´s type error have you?
    perhaps external libraries (located in classpath) invoke opsCommon.jar and config-3.0.jar classes. then, classnotfound is normal.
    and... why separate external libraries (opsCommon.jar and config-3.0.jar inside ear, and other in classpath)?

  • 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

  • Accessing Jar contents

    Hi everyone,
    I'm sorry to ask such a dumb question, but I'm still e newbie with Java.
    Ok here goes:
    How can I access the contents of a Jar file, for example images in a package, like:
    com.mypackage.images ----> images that I need to access.
    I used the example of images for simplicity but the contents of the jar file could be anything, like database drivers, or other classes.
    Thank you in advance.
    Chris

    It's really quite easy; if your entire application is in the same jar-file it will be just as if you weren't using jars at all. To use classes in a different jar-file, that jar-file just has to be put in the classpath-variable, and all the classes inside will be accessible.
    Not sure what you meant about the images - if you were talking about a class named images, a package or actual images to be loaded. In the latter case, there are a few differences from otside of a jar-file:
    // If your images are outside the jar:
    Image img1 = Toolkit.getDefaultToolkit().getImage("nameOfImage.png");
    // If your images are inside the jar:
    Image img2 = Toolkit.getDefaultToolkit().getImage(getClass().getResource("nameOfImage.png"));

  • ASP Accessing Jar

    Is there any info on how ASP can access and get information from a jar on a server?

    Is there any info on how ASP can access and get
    information from a jar on a server?Dear god you're an idiot.

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

  • Accessing jar inside  javascript

    Hi,
    Is there way to access a jar inside a javascript?

    BigDaddyLoveHandles wrote:
    anu1 wrote:
    HTML mailto has 255 character limit. I need to send more than 7000- characters in its body. Any advise how it can be done.
    Some body suggested me to use jar inside a javascript.Very good. Next time you ask a question, why not provide this sort of detail?Better still, next time you get ridiculous-sounding advice, ask the person who gave you that advice for more details. Or why you should do that. Or how you should do that. Because that particular piece of advice isn't just ridiculous-sounding, it's just plain ridiculous.
    Or it's possible you weren't really given ridiculous advice, it's possible you misunderstood. In which case asking the person who gave you the advice to clarify it would have been a good strategy too.

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

  • 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

  • Accessing jars

    Using oracle AS 9.04. An app I have inherited used to access some jars via
    <library path="../applications/<app_name>/<example.jar>" /> in server.xml.
    Can I do the same at 10g by moving the xml configuration to the system application file?
    thanks

    Which version of 10g -- there's R2 (10.1.2) and R3 (10.1.3).
    The tag is still valid in R3, but I'd encourage you to look at using shared-libraries instead of this approach -- you can deploy your JAR(s) as a named/versioned shared-library and then import them into the default application (ie j2ee/home/config/application.xml).
    We don't recommend modifying the system-application.xml file -- it's largely an internal construct. Use the application.xml file instead which is the config file of the default application and thus the visible parent of all deployed applications.
    cheers
    -steve-

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

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

  • Accessing Jar resource issue (in Junit test)

    Hi,
    I have a package called my.test.example containing one class called Example1.class and a property file called MyProp.properties. I am trying to load the content of MyProp.properties with the following:
    static {
        Properties Configuration = new Properties();
        try {
           URL url = Example1.class.getResource("/MyProp.properties");
           Configuration.load(url.openStream());
        } catch (IOException ex) {
            LOG.severe("Cannot load MyProp.properties :\n" + ex.toString());
    }The url is systematically null. I have tried including the package name, to use '/' instead of '.', but it does not work. How should I proceed? I am looking for a solution that works wherever the .jar is installed. Is this possible?
    Thanks.
    P.S.: I am working under Vista and the static code is invoked in a Junit test. I don't know whether this has an impact on the issue (but I don't think so).

    OK. Solved the issue with:
    Configuration.load(Example1.class.getResourceAsStream("MyProp.properties"));I had to solve another 'hidden' bug in the code.

Maybe you are looking for

  • I reset my iPod completely, and now it won't connect to computer. What happened?

    Just what the title states. My iPod was messing up so I reset it, and now it will not connect to a computer. I have tried other iPods on my computer and they all connect fine. Why is my iPod the only one doing this? Oh and by the way, the only screen

  • TS3297 keep getting error code 5002 when attempt to purchase music

    code 5002 when attempting to buy music

  • Cards app: how to delete saved cards

    In the Cards app: Ow can I delete cards that I have previously saved but no longer want anymore? I can't find a way to do it anywhere, please help me out! And if it isn't an option, why the heck not? I've only sent a total of three cards, but I have

  • Formatting array output

    how do i format the output of an array so that only a certain number of the elements print per line. i know this is basic, i am a beginner and need help.

  • AFX wont load on Mac OSX 10.9.2

    Ok - I'm on the new black trash can - 3.5 ghz - 6 core intel xeon E5 Premiere opens and runs no proeblems, but AFX wont open an gives the warning - you cant use this verision of AFX 0S 6 on this version of OSX Is there any easy way to fix without goi