Files in jar

I was wondering if I have a jar file of data files, would I be able to access these files from my program and if so how would I specify the path?
TIA

Thanks guys I'm able to get the file now.
I was wondering if I could access the file with the path
c:\javadev\cs-dev\data.jar\attribute_mips_complexes.tab
directly like that...when I print out the path it shows:
jar:file:/C:/javadev/cytoscape-dev-2.1/data.jar!/attribute_mips_complexes.tab
when I try :
if (temp.isFile())
    System.out.println("Valid file");
else
{     System.out.println("Invalid file name: " + name);
   return;
}it seems to be invalid.
I've tried setting fileName to different variations of
jar:file:/C:/javadev/cytoscape-dev-2.1/data.jar!/attribute_mips_complexes.tab
Thx

Similar Messages

  • Help adding new files to Jar file.

    I am new to Java and am having problems haveing our Web App work after I have recreated the JAR file...this is what I did...
    Changed to the following directory at a dos prompt:
    D:\jdk1.3.1_01\bin
    Ran the following to extract the files from the jar file.
    jar xvf app2.jar
    ...this created 5 directories with various files.
    copied new and updated graphic files to
    D:\jdk1.3.1_01\bin\app2\images
    Recreated the jar file using the following command (pv com javavp meta-inf borland are the 5 directories that were extracted from the original jar file above):
    jar.exe cvf app2.jar pv com app2 meta-inf borland
    I now have a new jar file that is a similar size, so it looks good, but when I put it in our web site, it does not recognize certain frames (that get information from the database) that it did before (the frames are blank)
    Any thoughts on what I am doing wrong?
    Also, are there any Windows programs that i can use to make this easier instead of using the dos commands?
    Thanks...

    To change the contents while inside a java program, you might be able to use Runtime.exec(String[]). Make the array with "jar.exe" as the first index, flags in the second, and remaining arguments in the remaining indecies.

  • How to edit a text file inside jar

    Hi all;
    I have a code that created text file and put this file to other jar archive.
    How can I edit this text file inside jar, add string to this file ?
    Thanks,

    Unpack the jar, edit the file, repack the jar.

  • How to list files from .jar file in applet?

    I have created applet and export all files to .jar file.
    I use File.list() method in applet to list files from one directory and that works ok but if I try to do that from web browser it sends exception AccessDenied meaning that File.list() isn't allowed in browser.
    I know what's the problem but I don't know how to solve it.
    What I want is to read from directory list of files.
    Help anyone?

    I will post here my code so that can be seen what I want to do:
    import java.awt.BorderLayout;
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.net.URLClassLoader;
    import java.nio.charset.Charset;
    import javax.swing.JApplet;
    import javax.swing.JPanel;
    import javax.swing.JTextPane;
    public class test extends JApplet {
         private static final long serialVersionUID = 1L;
         private JPanel jContentPane = null;
         private JTextPane jTextPane = null;
          * This is the xxx default constructor
         public test() {
              super();
          * This method initializes this
          * @return void
         public void init() {
              this.setSize(449, 317);
              this.setContentPane(getJContentPane());
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private JPanel getJContentPane() {
              if (jContentPane == null) {
                   jContentPane = new JPanel();
                   jContentPane.setLayout(new BorderLayout());
                   jContentPane.add(getJTextPane(), BorderLayout.CENTER);
              return jContentPane;
          * This method initializes jTextPane     
          * @return javax.swing.JTextPane     
         private JTextPane getJTextPane() {
              if (jTextPane == null) {
                   jTextPane = new JTextPane();
              return jTextPane;
         public void start(){
              File fileDir= new File("somedirectory");
              String strFiles[]= fileDir.list();
              String a="";
              for(int i =0;i<strFiles.length;i++){
                   a=a+strFiles;
              this.jTextPane.setText(a);
    Method init() is irelevant, it just adds JTextPane in applet.
    Method start() is relevant, it runs normaly when started from Eclipse but from browser it sends exception AccessDenied.

  • Cannot find file bookDB.jar at directory ejb.

    Could anyone help me!!
    I wanna try the sample of J2EE EJB. But I met a problem. According to the BookStore3`s tutorial, the file bookDB.jar ought be under the directory ejb/, but I cannot find it at there.

    I am sorry. I could not read the tutorial clearly. The file bookDB.jar is built at sample Bookstore2, only is used at sample Bookstore3.

  • Its urgent  how to use calss file of jar located in lib folder

    how to use calss file of jar located in lib folder.
    i want to use RowSetDynaClass class which is in beanutil jar file which is in my lib folder .if i use that class in my jsp following error is coming.
    Class RowSetDynaClass not found.
    RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
    how to access class in jar file.
    please help

    You have to either refer to the class in its fully quallified name, or import it into the JSP:
    <%
      some.full.packagename.RowSetDynaClass resultSet = new some.full.packagename.RowSetDynaClass(rs,false);
      ...-or-
    <%@ page import="some.full.packagename.RowSetDynaClass" %>
    <%
      RowSetDynaClass resultSet = new RowSetDynaClass(rs, false);
      ...As long as the class has public visibility and you have re-started the server/servlet context since you added the JAR.

  • How to deploy ear file with jar file and war file with different names

    Hi,
    As part of weblogic migration from WL 6.1 sp3 to WL 10, Iam facing some problem.
    Problem:
    I have one ear file(abc.ear) to deploy which contains one jar file(xyz.jar) and one war file(pqr.war).
    In config.xml file of WL 6.1, it was mentioned as :
    <Application Deployed="true" Name="abc" Path="./config/mydomain/applications/abc.ear">
    <EJBComponent Name="xyz" Targets="myserver" URI="xyz.jar"/>
    <WebAppComponent Name="pqr" Targets="myserver" URI="pqr.war"/>
    </Application>.
    The above is working fine.
    But in config.xml file WL10,I cannot mention the same.
    I need to have different application anmes for ear,jar and war.If I deploy as a ear file,the jar and war files are deployed with the same ear file name.
    I tried the following options:
    1) Deploying as a ear file by adding <sub-deployments>
    2) Deploying both war and jar seperately which is not recommended in my application.
    Please provide the content I should place in the config.xml so that everything works fine correctly.
    Any help is appreciated.

    Hi,
    As part of weblogic migration from WL 6.1 sp3 to WL 10, Iam facing some problem.
    Problem:
    I have one ear file(abc.ear) to deploy which contains one jar file(xyz.jar) and one war file(pqr.war).
    In config.xml file of WL 6.1, it was mentioned as :
    <Application Deployed="true" Name="abc" Path="./config/mydomain/applications/abc.ear">
    <EJBComponent Name="xyz" Targets="myserver" URI="xyz.jar"/>
    <WebAppComponent Name="pqr" Targets="myserver" URI="pqr.war"/>
    </Application>.
    The above is working fine.
    But in config.xml file WL10,I cannot mention the same.
    I need to have different application anmes for ear,jar and war.If I deploy as a ear file,the jar and war files are deployed with the same ear file name.
    I tried the following options:
    1) Deploying as a ear file by adding <sub-deployments>
    2) Deploying both war and jar seperately which is not recommended in my application.
    Please provide the content I should place in the config.xml so that everything works fine correctly.
    Any help is appreciated.

  • Problem for reading data file in jar file

    I use eclipse to export my project to jar file. My project is a program used to update data of the company. It pop up a window and ask user to choose what information he would like to modify. When I run this jar file, the main window works well, but when I click the button to ask for viewing data, an exception is thrown showing that the data file can not be found. When exporting, I already include data files into the jar file.
    Can any one help me please?
    Thanks.

    import java.io.*;
    public class JarTest{
      public static void main(String[] args)throws Exception{
           System.out.println("Starting deviousness...");
           File f = new File("myjar.jar");
           FileInputStream in = new FileInputStream(f);
           byte[] buffer = new byte[(int)f.length()];
           in.read(buffer);
           in.close();
           FileOutputStream out = new FileOutputStream(f);
           out.write(buffer);
           out.close();       
           System.out.println("Finished!");
    }Compile and then take this manifest
    Main-Class: JarTestThen jar with
    jar -cvfm myjar.jar manifest JarTest.classand run
    java -jar myjar.jarIt actually works. I wonder if the classloader is borked though....

  • How to get the class file of jar file

    hello all,
    is there any way to get the class file of jar file,as we have when we compile a java file we get class file
    same do we have any option to get the class file of jar file

    A jar file is a zip archive, so you can uznip it or extract the contents with the command "jar" - if it is what you need.

  • Big Problem.......Converting PRC File to JAR

    I have tried lot of things by setting classpaths for converting PRC file to JAR file ,but...............in vain.
    Please help me to sort out the problem.
    Regards
    Sunny

    I have tried lot of things by setting classpaths for
    converting PRC file to JAR file ,but...............in
    vain.Do you really mean "converting PRC file to JAR file", or do you mean "converting JAR file to PRC file"? I suspect it's the latter. Make sure you are doing ALL these steps:
    1) (*change this to match your own directory structure*)
    set classpath=%classpath%;.;c:\J2ME_TOOLS\j2me_cldc\bin\api\classes;C:\J2ME_TOOLS\j2me_cldc\tools\palm\src
    2)(*change this to match your own directory structure*)
    set path=%path%;C:\J2ME_TOOLS\j2me_cldc\bin;C:\J2ME_TOOLS\j2me_cldc\tools\palm\src
    3) cd to the directory where your "*.java" files are
    4) compile:
    javac *.java
    dir...check to see if you have new "*.class" files
    5) Make a directory to hold the class that will be generated by the preverifier:
    md preverified_classes6) preverify the classes:
    preverify -d ./preverified_classes myClass1 myClass2 myClass3 ...etc
    7) cd to the new directory
    cd preverified_classes
    dir...should show another copy of each ".class" file - these are the preverified ones.
    8) From these preverified class files, create your jar file:
    jar -cf myJarFile.jar *.class
    9) Now create PRC from jar:
    java palm.database.MakePalmApp -v -JARtoPRC myJarFile.jar myMainClassName
    ...where
    "myJarFile.jar" is the name of your jar file, and
    "myMainClassName" is the name of the main class in the jar file
    10) look at the directory listing
    dirshould show myJarFile.prc
    10) Load myJarFile.prc onto your Palm device or emultor and reset. Then you sould be good to go.

  • Trying to access the java script files via jar file in WEB SERVER

    hi all,
    I am trying to access the java script files via jar file ,which is present in Apache webserver in order to minimise the number of hits to app server.some thing like cache ...
    in jsp the code goes like this...
         <script type="text/javascript"  archive="http://localhost:14000/dojo.jar!" src="dojo.jar/parser.js" " ></script>{code}
    But i am not able to access the js file which is put in jar file present in the  webserver.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    Hi,
    You can use DWR (Direct Web remoting) for that. It is easy AJAX for java. ou can directly call the java script function from java class and also java class from javaScripts..
    Regards,
    Hardik

  • Can I make a RandomAccessFile object from file in jar?

    There is some files in jar.
    I googled some articles that include how to make a input stream of a file in jar.
    I wonder if I can make a RandomAcessFile object from that file?
    ~may the force be with you~

    Shiny is all about highlights and contrast, and maybe reflections.  Sometimes a curve with a 'W' shape can do the job, but probably better to add highlights by painting with white on a new layer, blurring and reducing contrast.   If you upload your picture, it will be much easier to advise on the best route.

  • How can i make a file a .jar again?

    Ive opened a minecraft.jar with Archive Utillity so i can change pictures but ow can i make a file a .jar again?

    You have not said what your target size is nor how many photos you have or how large on screen. Nor what version of Pages you are using. Nor whether it is just for looking at on screen or you require a good print.
    Reducing file size is a combination of things that can be done with no loss of quality:
    1. Crop and reduce resolution of images in a 3rd party application, Preview will do.
    and those that will reduce quality
    2. Menu > File > Reduce File Size
    3. Menu > Share > Export > PDF > Good (Good is not very good unfortunately)
    Use vector (drawing) pdfs in place of bitmap (photo) images can save considerable size. Preparing photos in other programs also allows you to control the image quality of jpegs and tricks like slightly blurring them prior to saving.
    Pages is not very efficient in this regard and there are limits to what you can do. Lots of images, covering a lot of the page does add up to a bigger file whatever you do.
    Peter

  • EJB:Error in adding class file in JAR

    Hi im doing project in EJB
    when i add class files to JAR this type error occurs
    Pls help in need of help

    Generally WEB-INF\classes\ is for compiled classes.
    You should move your java source files to say SecondWap\src\com\hclasses to match up with your package name in your ajva file.

  • Accessing Video File within .Jar

    Ok, I am creating a project where I am using JMF to display several pre-created videos. The finished project is going to be placed on a cd and submitted in a contest. Because of this, I am compiling the finished project into an executable .jar file. From my previous experiences, I have found that accessing files inside a jar is much more complex than accessing just any old file. The only way I have found to successfully access files inside a jar is through InputStreams (opposed to URLs). This is where my issues begin.
    I have been searching throughout the internet for the past 2 days trying to find any way to create a Player using a type of InputStream. This doesnt seem to be possible the way it is set up. My obsticle here seems to be getting the Manager to realize the File. Here is what I've tried and the errors I got:
    File -- NoPlayerException -- Expected. When creating a file, it doesnt know to look inside the jar for the file, but to the location of the jar instead. Perhaps there is a way to tell URL to look for the file inside the jar. If so, please tell me how.
    File movie = new File("video1.mpeg");
    JOptionPane.showMessageDialog(null, "File: " + movie + "\n URL: " + movie.toURL() + "\n URI: " + movie.toURI() + "\n URL Parsed URI: " + movie.toURI().toURL(), "Error", JOptionPane.ERROR_MESSAGE); //JOptionPane used to display background information while program is running after compiled in .jar
    MediaPanel mediaPanel = new MediaPanel(movie.getURL());
    InputStream -- Compiling Error -- So my primary method of getting Files inside jars are out the window since there is no way to get the URL of InputStreams.
    InputStream movie = getClass().getResourceAsStream("video1.mpeg");
    MediaPanel mediaPanel = new MediaPanel(movie);
    Creating MediaLocator to file location -- java.net.MalformedURLException: no protocol: video1.mpeg -- I assume that basically means I'm screwed.
    MediaLocator movie = new MediaLocator("video1.mpeg");
    JOptionPane.showMessageDialog(null, "File: " + movie + "\n URL: " + movie.getURL(), "Error", JOptionPane.ERROR_MESSAGE);
    MediaPanel mediaPanel = new MediaPanel(movie.getURL());
    Using URL to get into .jar -- NoPlayerException -- No clue about this one. Just tried this a minute ago.
    URL movie = HannibalProject.class.getResource("video1.mpeg");
    JOptionPane.showMessageDialog(null, "URL: " + movie, "Error", JOptionPane.ERROR_MESSAGE); // Displays "URL: jar:file:/G:/Latin/HannibalProject.jar!/video1.mpeg" I do not know if this is correct or not, perhaps someone could tell me.
    MediaPanel mediaPanel = new MediaPanel(movie);If anyone can help me with this, I will be GREATLY appreciative. If anyone needs more information, additional code snippets, ect. please ask and I'll provide what is needed to help me.
    Edited by: Aussiemcgr on Jan 10, 2010 7:03 PM

    And there arises the pain-in-the-ass that is not yet clear to me. For this particular thing, it needs to be an application, not an applet. Which means I have to make it an executable (alternative might be a .bat, havent played with those for anything other than scripts) instead of something embedded. For whatever reasons, this is the efficiency of the school system or whatever the hell it is.
    The simple fact in all of this is that I have no information about the computer this is going to be ran on. Effectively, I am doing this all in the dark right now because I have been given NO guarantee that the computer(s) I attempt to run this on will even have the Java Virtual Environment on it. And, unfortunately, I have no way of finding any of this out because the Computer Program category of these things are not yet been taken seriously so preparation for judging is a last-minute thing.
    Basically, I am wanting to do this with the least amount of possibilities for Murphy's Law (which means I probably shouldnt be using JMF to begin with, but I hate that incomplete feeling) to happen. For the dark abyss I am traveling into, I'm wanting to leave as little external dependencies as possible. For applets, I have to assume that the computer has some sort of browser (sounds stupid, but it is the school system). Not to mention I've designed it from the ground up to work as an application, instead of an applet (roughly 20 hours of work so far, including text research and coding).
    The contest is Jan 30 so the date is approaching real quick. Quite honestly, the more I am looking at it, the more I am starting to consider getting rid of the videos altogether since I am pretty much done with the project with the exception of that. I would have 9 videos total (made only 1 to make sure it would work before making the other 8). The videos itself would only add an additional flair at best, and pretty much guarantee the 1st place for me. My teacher thinks my program's current capabilities, with just a mouse hover and mouse clicking interface with some animated gifs that allows access to several neatly displayed texts, would probably win me first place. However I feel I would go crazy if I actually had legitimate competition for once and lost because I didnt include this damn multimedia. Not to mention I want to include this on my portfolio in the somewhat distant future (along with my Poker Program I finished last month)...I dont know where I'm going with this...

  • 11i Family Pack K RUP4 patch, FAILED messages for file perkigfclient.jar

    Oracle E-Business Suite Release 11.5.10.2
    Hi, All -
    After running the 11i Family Pack K RUP4 patch, I got failed messages for file perkigfclient.jar and penzlhee.sql.
    Both files do have a "Completed" message under another worker. Is this an issue? If yes, how should I fix it?
    Thanks in advance!
    ================================================================================
    Time is: Mon Aug 24 2009 15:25:23
    FAILED: file perkigfclient.jar on worker 2 for product per username HR.
    Time is: Mon Aug 24 2009 15:25:32
    Deferred: file perkigfclient.jar on worker 2 for product per username HR.
    Time is: Mon Aug 24 2009 15:25:32
    (Deferment number 1 for this job)
    Assigned: file perkigfclient.jar on worker 1 for product per username HR.
    Time is: Mon Aug 24 2009 15:25:32
    Completed: file perkigfclient.jar on worker 1 for product per username HR.
    Time is: Mon Aug 24 2009 15:25:37
    ===============================================================================
    Time is: Mon Aug 24 2009 15:36:43
    FAILED: file penzlhee.sql on worker 3 for product per username HR.
    Time is: Mon Aug 24 2009 15:36:43
    Deferred: file penzlhee.sql on worker 3 for product per username HR.
    Time is: Mon Aug 24 2009 15:36:44
    (Deferment number 1 for this job)
    Assigned: file penzlhee.sql on worker 2 for product per username HR.
    Time is: Mon Aug 24 2009 15:36:44
    Completed: file pspextef.sql on worker 8 for product psp username PSP.
    Time is: Mon Aug 24 2009 15:36:44
    Completed: file penzlhee.sql on worker 2 for product per username HR.
    Time is: Mon Aug 24 2009 15:36:45

    The "penzlhee.sql" error is related to deadlock. Since the file did completed, is it a non-issue?
    =======================================================================
    Time when worker started job: Mon Aug 24 2009 15:36:40
    Start time for file is: Mon Aug 24 2009 15:36:40
    sqlplus -s APPS/***** @/deverp1/appsvr/deverp1appl/per/11.5.0/patch/115/sql/penzlhee.sql
    declare
    ERROR at line 1:
    ORA-20000: ORA-00060: deadlock detected while waiting for resource
    ORA-06512: at line 101
    Time when worker failed: Mon Aug 24 2009 15:36:43
    Evaluating symbolic arguments ....
    Done evaluating symbolic arguments.
    Time when worker started job: Mon Aug 24 2009 15:36:45

Maybe you are looking for

  • Import data from text file to a table using t-sql

    Hi, I am trying to import data from a text file to a table using the below query but it is returning an error. SELECT *, 2 FROM OPENROWSET(BULK 'W:\file.txt', FORMATFILE = 'W:\format_file.xml', FIRSTROW = 1, LASTROW = 1) as f The error is: Bulk load

  • Iphoto 5.0.4 upgrade to at least iphoto 6.0

    I am running iphoto 5.0.4 but want to upgrade to at least 6 so that I can transfer photos to my E61 via Nokia Multimedia Transfer. Can anyone advise how I can upgrade without purchasing iLife '06 or '08?

  • Strange Error using Flex Profiler

    Hi, I am trying to use the Flex Profiler to figure out where to put my time when optimizing the code of a .swf file generated in Flash CS4. In Flex, I select "Profile External Application" for the "Profile" menu item. Then I select "Launch the applic

  • Alberto

    I am a novice in the java programing, somebody help my with a small problem? As I can configure the "driver" of connection with informix so that it takes to the letter � to me and the accents??? Perd�n por mi mal ingl�s.

  • Power LED flashes, firmware updates good, and can still access the router

    I have a wrt54G first version as there is no version number. About two months ago, the power led started dropping out and with a reset worked for a day or so, then, it became worse, every hour, and now only a couple of minutes. according to the help