Accessing a jar file

Hi all
Is it possible to access a txt file that is in a jar file???
That is , I've created a jar file that contains a txt file, now in my script, I need to access this txt file, is this possible?
Thanks , Dave

Yes.
See http://java.sun.com/docs/books/tutorial/jar/index.html for the specific details and sample code.

Similar Messages

  • How To Access a jar file present outside the war file through a jnlp

    Aoa
    I m new to this forum
    I m having problem with my jnlp file
    i want to know is there any way to access a jar file through jnlp.The problem is that my jnlp file is present in the war file
    and i want to know how to acess a jar file through this jnlp.The scenerio is as below
    I m using ear file on jboss.Its hirerchy is as
    -PAN-war.war
    -launch.jnlp
    -PAN-app-client.jar
    my jnlp file is as follows:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="http://localhost:8080/" href="PAN/launch.jnlp">
    <information>
    <title>PanEmirates</title>
    <vendor>M Fazal Ur Rehman</vendor>
    <description>PanEmirates</description>
    <description kind="short">PanEmirates</description>
    <homepage href=""/>
    </information>
    <security>
    <all-permissions/>
    </security>
    <resources>
    <j2se version="1.5+"/>
    <jar href="PAN-app-client.jar" download="eager"/>
    <jar href="lib/javafxrt.jar" main="true" download="eager" />
    <jar href="lib/Filters.jar" download="eager"/>
    <jar href="lib/javafx-netbeans-fxuserlib.jar" download="eager"/>
    <jar href="lib/swing-layout-1.0.3.jar" download="eager"/>
    </resources>
    <application-desc main-class="net.java.javafx.FXShell">
    <argument>pan.Main</argument>
    </application-desc>
    </jnlp>
    when i run launch.jnlp file it says unable to download resource http://localhost:8080/PAN/PAN-app-client.jar
    how to access this jar file
    Any help or comment would be highly appreciated
    Regards
    M Fazal Ur Rehman

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • Can't able to access the Jar files which is kept inside the folder.

    Hi,
    I am using the eclipse IDE, my project folder contains the folders src, bin, .metadata, .settings
    if i place the jar file in the same location of the above mentioned folder means i can able to use the Jar file in eclipse(in my project).
    But i create one folder in the same location in the name of Jar or anything and all jar files are placed inside the folder,then i can't able to access the jar file in eclipse(in my project).
    How i can solve this problem?

    RajivGuna wrote:
    ..How i can solve this problem?Put Eclipse aside for the moment and learn how the SDK tools work at the level of the command line, then you will be much better placed to figure how to do it in the IDE. If you are still having problems, I suggest you ask on an [Eclipse forum|http://www.eclipse.org/forums/].

  • How to access a jar file in EAR file?

    I have a EAR file which contains EJB.jar file and util.jar file. Outside of EAR, I mean in client side, I need to reference util.jar file. How can I access it?
    EAR structure is
    |--+META-INF/
    |--|---application.xml
    |--|---manifest.mf
    |--EJB.jar
    |--|---+MEAT-INF/
    |--|---|--- deployment descriptors...
    |--|---|--- manifest.mf
    |--|--- EJB classes
    |--Util.jar
    Util.jar must be executed in server side. If I just add Util.jar in client program's classpath, when client program is executed, serverside Util.jar is executed? Or what else I should do in the client program to reference server-side Util.jar?

    Excellent question. I don't see any client-jar in your EAR file structure. So I am assuming you are writing a separate client application which will talk to the ejbs deployed as part of this EAR. You need to do the following:
    Write another EAR file with the following structure:
    ear:
    META-INF/application.xml
    util.jar
    client.jar
    client.jar should have a META-INF/MANIFEST.MF and that should contain Class-Path:util.jar and value for Main-Class attribute.
    Now deploy this new ear to your application server and execute it using Application Client Container that comes with your app server.
    If you don't want to write another EAR file, then bundle th client.jar in your original EAR file.
    Points to note are:
    you have to repackage util.jar again inside this ear file.
    For portability reason, you should use Class-Path manifest entry in client.jar. Refer to http://java.sun.com/j2ee/verified/packaging.html and J2EE platform spec section #8.2.
    Hope this helps,
    Sahoo

  • Java Access Helper Jar file problem

    I just downloaded Java Access Helper zip file, and unzipped, and run the following command in UNIX
    % java -jar jaccesshelper.jar -install
    I get the following error message, and the installation stopped.
    Exception in thread "main" java.lang.NumberFormatException: Empty version string
    at java.lang.Package.isCompatibleWith(Package.java:206)
    at jaccesshelper.main.JAccessHelperApp.checkJavaVersion(JAccessHelperApp.java:1156)
    at jaccesshelper.main.JAccessHelperApp.instanceMain(JAccessHelperApp.java:159)
    at JAccessHelper.main(JAccessHelper.java:39)
    If I try to run the jar file, I get the same error message.
    Does anyone know how I can fix this?
    Thanks

    Cross-posted, to waste yours and my time...
    http://forum.java.sun.com/thread.jsp?thread=552805&forum=54&message=2704318

  • Custom Fault Policy java class is not able to access mediator.jar file

    Hi,
    I am trying to implement the custom java class for mediator fault handling. However when this class is invoked its not able to access the "oracle.tip.mediator.common.error.recovery.MediatorRecoveryContext" class during run time (which exists in mediator.jar). However its able to access all the other imported class files which exists in other library files.
    Do we need to add mediator.jar to the weblogic classpath manually or should we place that jar file in some location in the server ?? Its currently residing in the path -- /app/oracle/product/soastg/11.1.0/SOA/soa/modules/oracle.soa.mediator_11.1.1/mediator.jar. I tried to copy the same jar into domain lib and admin lib path but there was no luck.
    Any input on this will be helpful.
    Thanks,
    Ramesh

    Hi Ramesh,
    Try out the following
    1) Copy mediator.jar from SOA_HOME>/soa/modules/oracle.soa.mediator_11.1.1 to <MW_HOME>//soa/modules/oracle.soa.ext_11.1.1/classes
    2) Goto <MW_HOME>//soa/modules/oracle.soa.ext_11.1.1/classes and run the following command:
    a. jar -xvf mediator.jar
    3) Now remove the jar file, i.e., mediator.jar from classes folder.
    4) Restart the server.
    Regards,
    Srijith

  • Accessing a Jar file within my jar...

    Hi,
    I've got a JDBC Jar file that I wish to include in my Jar package, but I'm unsure how to do this...
    I'm using ant to compile my code & package it up into the Jar, & I can get it to compile fine, and package everything up fine (including the JDBC jar), but when I go to run the app I get an error
    (No suitable driver).
    My app works fine without being Jar'ed up.
    I'm guessing that I need to set the classpath to reference the JDBC jar file in my jar... but I'm unsure how to do this.
    Any help would be greatly appreciated.

    package what you thirdpart jar file and your jar file to one jar file..
    it will run ok.
    maybe the below tool can help you.
    a tool named JavaJar(written by java) can compress and decompress jar,war, ear and.zip...
    may download from http://www.qwerks.com/download/4114/JavaJar.zip
    the tool is very verygood tool.
    but the homepage(www.pivotonic.com) of JavaJar cannot be accessed.
    it is funny.
    good lucky.

  • Accessing of JAR file.

    Hi,
    Is there a way of disable the source code in the JAR file from being use by people who are not suppose to use it.
    Basically, I am writing a software and need to distribute a library with it but I don't want anyone else to access this library apart from my software.
    Thanks.

    Try this,
    First compile with javac, and then run jar.
    Use jar like this: jar cf filename.jar dirname/*.class
    Or just jar cf filename.jar *.class

  • How to access jdbc jar file using JWS - Hlep needed

    hi guys i am having a problem running jdbc jar files (msutil,msbase,mssqlserver) using JWS. I am able to downlod it to the client machine but i am getting an error
    java.sql.SQLException: [Microsoft][SQLServer 2000 Driver for JDBC]Error opening/loading com.microsoft.util.transliteration.properties.
    i am able to run it locally. but using JWS in my machine itself is generating this error. In general what am i supposed to do to run an application using jdbc through JWS. I am able to download the jar files do i need to do anything more. Your help will be well appreciated.
    thanks,
    ravi.

    hi guys i got the problem solved i was not metioning security tag in the jnlp file with all permissions.
    thanks,
    ravi.

  • How to access classes in jar files

    hi I have added a jar file to my project in eclipse.How to access the classes in that jar file?

    cu is right.
    classloader returns the URL of your resource. You can the jar using something like the following...
    ClassLoader classloader = this.getClassLoader();
    url = classloader.getResource("your_resouces...");
    if(url == null)
    System.out.println("cannot find resource ");
    return null;
    String jar = url.getFile();
    jar = jar.substring(jar.indexOf("/")+1, jar.lastIndexOf("!")).replace('/', '\\');
    obviously, this code snippet works on windows only. Now you have the jar file path. I use Jar file classes to access the jar file. (e.g. you can search for each class files)
    Ming

  • 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

  • Multiple jar files from different locations

    Hello,
    I am having an applet that access code from two different jar files. Of them one is a common jar file for many applets. So I couldn't place it in the local dir as that of the applet's html. I am not using any web server.
         Just to give you a feel of it :
         <PARAM NAME = archive VALUE = "DVApplet.jar,DVVP.jar" > are the jar files my applet is dependant on. But DVVP.jar has to be accessed from a dir different from local dir.
         Will be glad if someone can throw some light on accessing different jar files from different dirs.
         Thanks for your time.
    Regards,
    Anantha

    [url=
    http://forum.java.sun.com/thread.jsp?forum=421&thread=425724&tstart=0&trange=100
    ]This question is a bit similar
    You can use a class loader to do such things.

  • Jar file in applet not saved in internet files when using jdk plugin

    Hello,
    I recently upgarded to jdk1.3.1 and converted our applet and classes to jdk1.3.1 using swing classes. From there, we converted the html file with htmlconverter and diployed this on the web. When a user goes to the web, the system automatically downloads the java plugins and installs them on the clients maching. From there our jar file loads and executes. Our applet runs fine. However, every time our website is accessed, our jar file cookie must be downloaded which is just over 1meg and I know this is not going to fly with our clients.
    What needs to be done so the jar file is not downloaded every time, to work like java version 1.x ?
    Thanks for your help in advance with this one.
    Jay Ford

    Hi Jay Ford,
    Enable the "Recycle Classloader" in Control Panel-->Java Plug-in1.3.1-->Basic.
    The main purpose of this Recycle classloader is it will enable the "javaplugin.classloader.cache.enabled" property to true and it caches the jar files for performance enchancement.
    Hope this will help you.
    Anil.
    Developer Technical Support,
    Sun Microsystems Inc,
    http://www.sun.com/developers/support

Maybe you are looking for

  • Error while the system is booting up

    I get the following error "rpcbindkeyserv: failed to generate host's netname while establishing root key" Solaris 5.7 Is this the cause for Oracle error: Ora-12560:TNS protocol adapter error? lee

  • Known Issues & Brtools Upgrade for SAP Netweaver 7.01 with Oracle 11.2.0.3?

    Hi, We are currently on Netweaver 7.01 with below SAP components running on Unix OS AIX 6.1 and Oracle DB 10.2.0.4 ERP 6.0 EHP4           CRM 7.0 BW 7.0 EP 7.0 Solution Manager 7.0 EHP1 on Windows Now, we are planning to upgrade oracle from 10.2.0.4

  • Import into 9.3 can take a few hours... even more than 24h?

    Hi, recently I updated iPhoto to 9.3, after that it opened up telling me to upgrade my old iPhoto-database. All of the 9 steps were finished with 100%, the popup-window closed itself and now iPhoto is showing me a spinning wheel for over 24h now. In

  • EliteBook Folio 9470n Fan 90B

    My laptop is only 5 days old and I am getting an error at start up that my cooling fan is not working and go to this message board for help mentioning Fan 90B. The only responses I see are to clean the vents and try again. Come on, this is a brand ne

  • I have to double click to read message and see pictures

    I hit something and it change how I see my mail. Before the mail would come in and I'd click once. The mail was opened and stayed open. Same with sent mail. I could see the message or picture after I sent it. Now I just have columns of names where th