Jar inside a jar

I would like to insert a jar (jar1) into another jar (jar2). I have extract all files of jar1 and then I construct jar2. But then when I click on jar2 I have the following message : "Could not find the main class".Is there something to add to the manifest? My manifest only gives the main class of jar2.

http://forum.java.sun.com/thread.jsp?forum=22&thread=405160&tstart=0&trange=100

Similar Messages

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

  • Unable to load classes from jar files inside APP-INF/lib in EAR.

    Weblogic version: 10.3.3
    Platform: Linux x86-64 bit
    We deployed an ear packaged with all the common library jars inside APP-INF/lib. Deployment was successful.
    for some reason, it is always giving ClassNotFoundException for the classes inside the jars. This does not happen
    in 10.3.2 version of weblogic.
    We tried to add them to domain/lib directory (instead of APP-INF/lib) but still it is not able to resolve the classes.
    Any pointers would be appreciated.

    try using prefer-web-inf-classes in the weblogic.xml file in your WAR file
    or using prefer-application-packages in the weblogic-application.xml file in your EAR.

  • File Not Found inside jar

    Hi All,
    Im using applet to access a wav file which is located in the jar file, 1st of all im compiling the applet class, making a jar file(which has the welcome.jar in it) and signing the jar file and then archiving the jar file in the HTML code. following is the code used in the java applet file.
                    URL pathShell = null;
         Object dummy = new Object(){
                                 public String toString() { return super.toString(); }
         ClassLoader cl = dummy.getClass().getClassLoader();
         pathShell  = cl.getResource("welcome.wav");
         String wavFile = pathShell.toString();
         System.out.println("path  --- "+pathShell);
         System.out.println("String -- "+wavFile);
         RandomAccessFile rcs = new RandomAccessFile(wavFile,"rw");Exception messages is as follows,
                   path  --- jar:http://localhost/slider.jar!/welcome.wav
                   String -- jar:http://localhost/slider.jar!/welcome.wav
                    java.io.FileNotFoundException: jar:http:\localhost\slider.jar!\welcome.wav (The filename, directory name, or volume label syntax is incorrect)
         at java.io.RandomAccessFile.open(Native Method)
         at java.io.RandomAccessFile.<init>(Unknown Source)
         at java.io.RandomAccessFile.<init>(Unknown Source)
         at AudioPlay.<init>(AudioPlay.java:40)
         at SliderDemo.startAudio(SliderDemo.java:231)
         at SliderDemo.access$000(SliderDemo.java:17)
         at SliderDemo$5.actionPerformed(SliderDemo.java:144)
         at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
         at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
         at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
         at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
         at java.awt.Component.processMouseEvent(Unknown Source)
         at javax.swing.JComponent.processMouseEvent(Unknown Source)
         at java.awt.Component.processEvent(Unknown Source)
         at java.awt.Container.processEvent(Unknown Source)
         at java.awt.Component.dispatchEventImpl(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
         at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
         at java.awt.Container.dispatchEventImpl(Unknown Source)
         at java.awt.Component.dispatchEvent(Unknown Source)
         at java.awt.EventQueue.dispatchEvent(Unknown Source)
         at java.awt.EventDispatchThread.pumpOneEventForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
         at java.awt.EventDispatchThread.run(Unknown Source)

    b.m.kraju wrote:
    Hi All,
    Im using applet to access a wav file which is located in the jar file, 1st of all im compiling the applet class, making a jar file(which has the welcome.jar in it) and signing the jar file and then archiving the jar file in the HTML code. following is the code used in the java applet file.You can't open a resource inside a jar file as a RandomAccessFile or any other form of File.

  • How to make an applet to read the Text file present inside a jar

    Hi All,
    I have writen one applet named ReadFile.java which reads a text file present in the same directory and does some manipulation of text file contents.
    The applet code runs successfully when i run the applet in command prompt like
    {color:#ff0000}*java ReadFile*{color}
    And i am getting the needed results.
    Then i made a jar file with the applet code and text file as
    {color:#ff0000}*jar cvf rf.jar ReadFile.class File1.txt*{color}
    Then i have inlcuded this applet inside a html file as
    {color:#ff0000}*<applet code= "ReadFile.class" width= "500" height= "300" archive = "rf.jar" ></applet>*{color}
    after this when i load the html file, the applet code is not executed fully. Its throwing FileNotFoundException: File1.txt.
    Applet is not recognizing trhe text file present inside the jar file.
    Can any body explain me how to overcome this problem. Any setting needs to be done for making the applet indicate the presence of Text file inside the jar file.

    what code in your applet gets the text file and reads it? are you using getResource or something similar?

  • How to look inside a jar?

    I am getting errors when using the sun deploytool. I think there is an ejb-jar.xml inside my ejb-jar file. how do i look at it?

    You can use the jar tool or any program that handles zip files (jar files are just zip files).

  • How to load a xml file from a package inside of a jar file

    hi@all
    my application has got a xml configuration file which is saved inside the package tree of the class that reads this file.
    when i`m developing using eclipse the class can find that file, everything works fine. but when i create a jar file of my application to use it in another application it cannot find that file anymore.
    can anyone tell me how to solve this problem, please?
    thx a lot
    dialsc

    hi all,
    the xml file is in the jar file and
    ClassLoader.getSystemResourceAsStream(..) solved my problem.
    in fact i did nameOfClassInSamePackageAsXmlFile.class.getResourceAsStream("nameOfFile.xml");thank you all
    greez
    dialsc

  • Problem with creation of a jar file from inside a java program

    Hi,
    I am trying to create a jar file at runtime from within a java program.
    I am able to create a jar file just fine using:
    String[] jarArgs = new String[3];
    jarArgs[0] = "cvf";
    jarArgs[1] = "C:\temp\myjar.jar";
    jarArgs[2] = "C:\temp\this";
    sun.tools.jar.Main main1 = new sun.tools.jar.Main(System.out, System.err, "jar");
    main1.run(jarArgs);However, when I look at the jar it puts the absolute path to the files inside such as:
    C:\temp\this\is\my\package\Class.class
    instead of only this\is\my\package\Class.class
    When running the jar command from the command line it works just fine and I have the relative paths in my jar file.
    Does anyone have any experience with this and could help me out?
    Thanks in advance
    Edited by: mruf on Apr 11, 2008 1:51 AM

    Shouldn't jarArgs[2] = "-C C:\temp\this"

  • How can i get the path to config folder placed inside the jar file?

    Hi i have developed an RCP application using eclipse.
    In my application config directory is there.
    When i export my RCP application as JNLP Project the jar file is created which contains config folder inside it.
    When i download the application using java web start , how can i get the path to config folder placed inside the jar file?
    Will the config folder exists in local cache in my system?
    Help needed.
    -Deepak

    -- This works in CS6:
    tell application "Adobe InDesign CS6"
      set myDocument to active document
      set selectedRectangles to selection of myDocument
      set theGraphicsLink to file path of item link of (graphic 1 of (item 1 of selectedRectangles))
    --> "Macintosh HD:folder/folder/filename.tif"
    end tell

  • JRE doesn't find the main class inside a JAR archive file

    Hello everybody,
    I've written a small application in Java, using NetBeans. Running my application inside NetBeans works fine, but I can't run it from the console or by double clicking the jar file.
    Running it from the console I get the following error message:
    java -jar TestApplication.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: tst.Benchmark
       at gnu.java.lang.MainThread.run(libgcj.so.81)
    Caused by: java.lang.ClassNotFoundException: tst.Benchmark not found in gnu.gcj.runtime.SystemClassLoader{urls=[file:TestApplication.jar], parent=gnu.gcj.runtime.ExtensionClassLoader{urls=[], parent=null}}
       at java.net.URLClassLoader.findClass(libgcj.so.81)
       at gnu.gcj.runtime.SystemClassLoader.findClass(libgcj.so.81)
       at java.lang.ClassLoader.loadClass(libgcj.so.81)
       at java.lang.ClassLoader.loadClass(libgcj.so.81)
       at gnu.java.lang.MainThread.run(libgcj.so.81)I know that these errors often come when the class path is not set in the right way, and using a single java file, you can fix this by passing the parameter "-cp ."
    I tried this with the jar file but it does not work and using "-cp TestApplication.jar tst/Benchmark" didn't work either.
    Inside the jar file I have the META-INF Folder and a "tst" Folder which contains all my class files. And I've set tst.Benchmark as the main class, this also stands in the manifest file correctly.
    Do you have any ideas what could be wrong?
    Greetings JavanianGuy

    This line
    at gnu.java.lang.MainThread.run(libgcj.so.81)says that you're using GNU's Java, not Sun's Java. They are not the same. GNU Java is incomplete.
    You'll need to ask this question at the GNU Java site.
    Recommendation: Use Sun's Java

  • How to Read all files inside resource Folder inside Jar?

    I have a Jar file,,,, The program reads for resource files in the resource folder inside the Jar. I want my program to read all files inside this folder without knowing the names or the number of files in the folder.
    I am using this to make an Applet easy to be updated with spicific files. I just want to add a file inside the resource folder and Jar the program and automatically the program reads what ever is in there!!
    I used the File class to get all file names inside the resource folder. it works fine before Jarring the program. After I jar I recieve a URI not Herarichy Exception!!
    File fold=new java.io.File(getClass().getResource(folder).toURI());
    String[] files=fold.list();
    I hope the question is clear!!

    How to get the directory and jar file that you class resides in:
    // returns path and jarfile (ex: /home/mydir/my.jar)
    public String getJarfileName()
            // Get the location of the jar file and the jar file name
            java.net.URL outputURL = YourClass.class.getProtectionDomain().getCodeSource().getLocation();
            String outputString = outputURL.toString();
            String[] parseString;
            int index1 = outputString.indexOf(":");
            int index2 = outputString.lastIndexOf(":");
            if (index1!=index2) // Windows/DOS uses C: naming convention
               parseString = outputString.split("file:/");
            else
               parseString = outputString.split("file:");
            String jarFilename = parseString[1];
           return jarFilename;
    }If your my.jar was in /home/mydir, it will store "/home/mydir/my.jar" in jarFilename.
    note: getLocation returns "file:/C:/home/mydir/my.jar" for Windows/DOS and "file:/home/mydir/my.jar" for windows, thus why I look for the first and last index of the colon so I can correctly split the string.
    If you want to grab a file in the jar file and get an InputStream, do the following:
    import java.io.*;
    import java.util.Enumeration;
    // jar stuff
    import java.util.jar.*;
    import java.util.zip.ZipEntry;
    public class Jaris
       private JarFile jf;
       public Jaris(String jarFilename) throws Exception
           try
                           jf = new JarFile(jarFilename);
           catch (Exception e)
                jf=null;
                throw(e);
       public InputStream getInputStream(String matchString) throws Exception
           ZipEntry ze=null;
           try
              Enumeration resources = jf.entries();
              while ( resources.hasMoreElements() )
                 JarEntry je = (JarEntry) resources.nextElement();
                 // find a file that matches this string from anywhere in my jar file
                 if ( je.getName().matches(".*\\"+matchString) )
                    String filename=je.getName();
                    ze=jf.getEntry(filename);
          catch (Exception e)
             throw(e);
          InputStream is = jf.getInputStream(ze);
          return is;
       // for testing the Jaris methods
       public static void main(String[] args)
          try
               String jarFilename=getJarfileName();
               Jaris jis = new Jaris(jarFilename); // this is the string we got from the other method listed above
               InputStream is=jis.getInputStream("myfile.txt"); // can be used for xml, xsl, etc
          catch (Exception e)
             // this is just a test, so we'll ignore the exception
    }Happy coding! :)
    Doc

  • Opening html files inside jar

    Hi,
    I'm making a program where i have a set of help files in the form of html and i would like to open them when the user clicks the "Help" button and I used this code at first
    try
         Desktop.getDesktop().browse(new URI("resources/html/help.html"));
    catch (Exception ex)
         JOptionPane.showMessageDialog(null, "Could not open help.html in default browser\n", "Error", JOptionPane.ERROR_MESSAGE);
    }However after I made the jar and tried to execute on another computer however, it wouldn't work and would display the error message. I was wondering if there was some way that I could open the help.html in their default browser, or maybe a frame if that works, from the jar and have my program still be platform independent?

    ok so i just realized that it doesn't make sense for a program outside the jar, like IE or Firefox, to be able to access and open a file inside of the jar. I am now looking for suggestions on how to work around this problem for my program to be able to have a simple help system located inside the jar that can be loaded during runtime.
    Thanks for your suggestions.

  • Running a batch file inside a jar

    HI all
    I created a jar file , in which i need to run a batch file , so i wrote a main class to execute the run the batch file , but when iam running the jar it is searching for the given batch file out side the jar.
    my code is some thing like below
         public static void main(String args[])
              try
                   Runtime rt=Runtime.getRuntime();
                   Process process=rt.exec("%DIRNAME%/start.bat");
       InputStreamReader reader =
                      new InputStreamReader ( process.getInputStream () );
                   BufferedReader buf_reader =
                       new BufferedReader (  reader );
                    String line;
                    while ((line = buf_reader.readLine ()) != null)
                                 System.out.println (line);
              catch (IOException e) {
                    System.out.println (e);
         }so please help me.. is it the problem in specifing the path...?
    are does it have any other method to read the stream functions ..
    thanks in advance
    sam

    I don't think this will work. You could not go to a command line and enter, "%DIRNAME%/start.bat" if start.bat was inside a jar - the CLI doesn't know how to read a batch file inside a jar.
    I think it would work to programmatically read the lines of start.bat (when it is inside the jar) into an array of Strings and use Runtime.exec with the array as the argument.
    It would also work to extract the start.bat file, then execute it using Runtime.exec.

  • Connecting to a database inside a JAR?

    Hi,
    Can I do the following:
    Connect to flatfile database inside the same jar as my program? i.e., would something along the lines of:
    jdbc:jar://db.txt
    work? And if so, what would be the correct way to do it, other than my horrible example above. If so, what database/jdbc driver can i use for it?
    Thanks in advance for all help!
    Stu

    You could retrieve the data but your gonna have problems when it comes time to update.

  • Call class inside a jar file??

    Hello group,
    I have a class with a main mathod and this class is inside a .jar file. This jar file reside under my
    web-inf\lib or class-path directory in my application at Weblogic Server.
    How can I call this class by command line?
    I have to create a cliente to do it?
    Is it possible? I´m having problems because the weblogic server is using the jar file at the same time that I trying use it calling by command line.
    Where can I find more information?
    Message was edited by:
    Denimar

    Authcloud9981 wrote:
    Hi I have an executible JAR file that I can call from command line by using the command - "java -jar file.jar".
    Is there a way for me to call this JAR file inside a Java class in another Java Program?There can be more going on in a jar than just as a container for classes.
    The manifest defines the behavior. So to replicate the behavior you must do exactly that.
    As an example of that.
    [http://java.sun.com/developer/Books/javaprogramming/JAR/basics/manifest.html#download]
    Additionally by running it in your application you must consider what the scope of that is. If you just load the classes directly then they will be in the system class loader and thus cannot be unloaded. Using a class loader solves that.

  • Resources inside JAR - problem

    I have a strange problem with resources inside JARs.
    I can't load any resource form a JAR file (for example a .property file or .png icon).
    It's not a problem with my progams only. JDBC drivers doesn't work because they cannot find .properties files while they work well when, the driver JAR i uncompressed. It happens every time when some resouces are inside JAR library (classes are loade correctly). The same project runs well on my friend's computer while I've got an error on my computer.
    I tried it on WinXP and Win2003 Server - the same. My java version 1.5.0_06-b05 (but I had the same problem with older versions).
    I figured out that I can find a file inside a JAR, open a stream, load data and everything is OK but data is always 0bytes length. For example using:
    ImageIcon myImageIcon = new ImageIcon(getClass().getResource(pathandfilename));
    I get empty ImageIcons without any error.
    Can anyone help me. Maybe I should find something somwhere in java configuration.
    Message was edited by:
    peper

    But can anyone tell me why my servlet can not access the
    contents inside a jar file?? Any suggestions please?
    Thanks.Without seeing your code, it is likely that you are trying to use file names (like /some/path/yourFileName.ext), not resource names (loadable from the class loader) like /yourFileName.ext.
    Example:
    Instead of:
    FileInputStream stream = new FileInputStream("/some/path/yourFileName.ext");
    do this:
    InputStream stream = getClass().getResourceAsStream("/yourFileName.ext");
    There are other API's which take either a string file name or a URL. You want to go the URL way, where the URL is taken from the classpath as:
    URL url = getClass().getResource("/yourFileName.ext");

Maybe you are looking for

  • Connecting ipod via a/v cable to projector...

    I was just wondering if anyone has tried connecting their ipod to a TV or a projector and seen if the quality is reduced because the screen is so much bigger. Can you only watch video in good quality on the ipod itself at 320X240, or can it expand cl

  • Itunes: Where is my video?

    This one I actually want to talk to a person but am unable to. I got a song I didn't want. I asked for a video atleast three times and in the coarse of asking for that video I paid atleast three times and yet no video. Just a song I didn't want in th

  • Website won't play SoundCloud widgets on Safari.

    My website at www.nishmusic.com contains SoundCloud widgets to play the music that I write.  (Example: http://www.nishmusic.com/published-works/the-magic-flute-in-5-minute-2.html)  For some reason, I can play but not hear the widgets.  I've reset Saf

  • Function for uploading  multiple images, say 5000 , of any type?

    Hi, I want to upload multiple images which are stored anywhere, be it a local system or a server, to the SAP database just by clicking a single button. The method should be able to pick all the images and check their file types and upload it. My conc

  • Error showing when attempting to install LabVIEW2009 on my computer (windows XP 32 bit)

    When trying to install LabVIEW2009 on my computer (windows XP 32 bit) I get the following error: The instruction at "0x005466a9" referenced memory at "0x00000000".  The memory could not be "read".   Has anyone any ideas why this is error is appearing