Adding Jar files in another Jar file

Hi,
I have a very bad problem. Please some one help me here.
I created a Java application which is organized in a package structure.
The directories and files in the JAr files are following
1) TestApplication.class - The application startup class.
2) com(dir) - The start of my package structure, all the othere files are in this directory
3) config (dir) - Directory containing all the configuration files.
4) hsqlDatabase (dir) - contains the inprocess database
5) images (dir) - Contains all the images used in the application.
6) lib (dir) - Contains all the other jar files that i use in this application, i have about 10 of them in this directory.
I created a jar file which contains all these dir and the TestApplication.class file. I also uses the 'Main-Class' and 'Class-Path' attribute.
This is my META-INF\MANIFEST.MF file
Manifest-Version: 1.0
Ant-Version: Apache Ant 1.6.1
Created-By: 1.4.2_03-b02 (Sun Microsystems Inc.)
Built-By: jj
Main-Class: TestApplication
Class-Path: .;./lib/commons-codec-1.3.jar;./lib/commons-httpclient-3.0
-alpha1.jar;./lib/hsqldb.jar;./lib/kunststoff-2_0_1.jar;./lib/kunstst
off.jar;./lib/liquidlnf.jar;./lib/log4j-1.2.8.jar;./lib/looks-1.2.2.j
ar;./lib/jcalendar.jar;./lib/mysql-connector-java-3.0.9-stable-bin.ja
r;./lib/ViolinStrings.jar;./config;./hsqlDatabase;./images
When i try to run the application through
java -jar xxxxx.jar
1) the first problem is that it starts the application (TestApplication.class) and also loads the rest of the application in my package(com\...). But it cannot find the classes which are in the jar file (in the lib dir).
2) I am also trying to read from a config\xxxxx.properties file, but i get an exception showing FileNotFound (xxxxx.properties).
Hope that this will help you to help with my problem,
Thanks in advance,
Jobby

1) the first problem is that it starts the
application (TestApplication.class) and also loads
the rest of the application in my package(com\...).
But it cannot find the classes which are in the jar
file (in the lib dir).
jars inside of jars do not work like you want them too. You should be able to write a class loader that can find those other jars, but Java does not directly support jars inside of jars. Of course, you can unjar the other jars and use them as well.
2) I am also trying to read from a
config\xxxxx.properties file, but i get an exception
showing FileNotFound (xxxxx.properties).
Is this file also in the jar? If it is, you need to use getClass().getResource() to find the file.

Similar Messages

  • Executing .jar files from another .jar file.

    How would I run one .jar file from another .jar file. and is there anyway to call specific class arguments? Because I have one .jar file that reads a specified file and returns its contents.
    So how would I execute it and specify its arguments and how would I make it return something to the executing jar file?

    Because I have one .jar file that reads
    a specified file and returns its contents. Presumably you have a class that does that, and you have that class stored in a jar. And you want to know how to... um... do something with that class. I say "um..." because normally you don't execute a class, either, you either call its static methods or you create an instance of the class and call its instance methods.
    If you have been writing a whole lot of little classes each of which just has a static main method, then stop doing that. Write real Java classes instead. The tutorial is here:
    http://java.sun.com/docs/books/tutorial/java/index.html

  • How to Include a ZUL file in another ZUL file

    Hi
    I need to Include a ZUL file in another ZUL file
    which is not in same JAR. Both are in different JAR.. but i want to Include that...!
    Thanks...!

    You want to include a ZUL file, whatever that is, that's in one JAR inside another ZUL file that's in another JAR? I don't even understand the question. Get it out of the first JAR and include it inside the 2nd ZUL file ???

  • Pooling data from an XML file to another XML file using File Adapter

    Hi,
    I am trying to Pool data from an XML file to another XML file using File Adapter. I have added "Target Namespace" in both the XML and XSD.The problem is "At the destination given in the FileAdapter" only a blank XML file is created and it doesnot have any data.
    Kindly suggest me some methods
    Thanks in Advance.

    Ok here is a solution with external tables.
    SQL> CREATE DIRECTORY my_xml_dir AS 'E:\oracle\Log_files\UTL_AKIVATST'
    2 /
    Directory created.
    SQL> DROP TABLE my_xml_et
    2 /
    Table dropped.
    SQL> CREATE TABLE my_xml_et
    2 ( EMPNO NUMBER,
    3 EMPNAME VARCHAR2(10),
    4 JOB VARCHAR2(10),
    5 HIREDATE DATE,
    6 SAL NUMBER
    7 )
    8 ORGANIZATION EXTERNAL
    9 (
    10 TYPE ORACLE_LOADER
    11 DEFAULT DIRECTORY my_xml_dir
    12 ACCESS PARAMETERS
    13 (
    14 records delimited by "</EMP>"
    15 badfile my_xml_dir:'empxt%a_%p.bad'
    16 logfile my_xml_dir:'empxt%a_%p.log'
    17 FIELDS
    18 (
    19 filler char(2000) terminated by "<EMP>",
    20 EMPNO char(2000) enclosed by "<EMPNO>" and "</EMPNO>",
    21 EMPNAME char(2000) enclosed by "<ENAME>" and "</ENAME>",
    22 JOB char(2000) enclosed by "<JOB>" and "</JOB>",
    23 HIREDATE char(2000) enclosed by "<HIREDATE>" and "</HIREDATE>",
    24 SAL char(2000) enclosed by "<SAL>" and "</SAL>"
    25 )
    26 )
    27 LOCATION ('emp.xml')
    28 )
    29 PARALLEL
    30 REJECT LIMIT UNLIMITED
    31 /
    Table created.
    SQL> SELECT * FROM my_xml_et
    2 /
    EMPNO EMPNAME JOB HIREDATE SAL
    7369 SMITH CLERK 17-DEC-80 800
    7499 ALLEN SALESMAN 20-FEB-81 1600
    This is the XML file i used emp.xml
    <EMPLOYEES>
    <EMP>
    <EMPNO>7369</EMPNO>
    <ENAME>SMITH</ENAME>
    <JOB>CLERK</JOB>
    <HIREDATE>17-DEC-80</HIREDATE>
    <SAL>800</SAL>
    </EMP>
    <EMP>
    <EMPNO>7499</EMPNO>
    <ENAME>ALLEN</ENAME>
    <JOB>SALESMAN</JOB>
    <HIREDATE>20-FEB-81</HIREDATE>
    <SAL>1600</SAL>
    <COMM>300</COMM>
    </EMP>
    </EMPLOYEES>
    Use this external table to insert into your table.
    Thanks,
    Karthick.

  • How can I copy layers from one .fla file to another .fla file?

    Hi,
    How can I copy layers from one .fla file to another .fla file? Please do help.
    Thanks.

    Select all the frames you want to copy, right click and select copy frames then select the file you want to paste them into and right click again and then paste frames.
    The layers the frames are should come across with them.

  • Move group of pages from one InDesign file to another InDesign File using VB.Script

    Dear team,
    I am trying to move group of InDesign pages from one indesign file to another indesign file using vb.script.
    I have written the code like
    Dim Pages=IndDoc.Pages
    Dim Mytype=TypeName(Pages)
    Pages.Move(InDesign.idLocationOptions.idBefore,IndDoc1.Pages.LastItem)
    but it is giving an error as method Move is not a member of Pages 
    please give mme the solution to move the Multiple pages or a group of page from one Indd to another Indd.

    Hey Peter, if I wan to move several page that part of Auto Flow text, I checked the "delete page after moving" but the content still there, not deleted.
    Is there any way to delete it automatically, just to make sure I have moved that autoflowed page?

  • Trying to compile a .java file from another .java file

    Hello,
    I'm trying to compile a .java file from another .java file using Runtime.exec...
    String c[]=new String[3];
    c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
    Process p=Runtime.exec(c);
    If anyone can help me in atleast getting the command prompt when Runtime.exec("cmd.exe") is executed...that would be great...I tried out notepad.exe, calc, explorer instead of cmd.exe...all the commands display their respective windows..except cmd.exe...the command prompt doesnt appear...
    Please help me ASAP....
    Thanks for your help in advance...
    Regards.
    AKhila.

    try this. ur code will be compliled and will get .class file. but console won't appear. is it a must for u?
    public class Exec{
         public static void main(String a[]) throws Exception{
              String c[]=new String[3];
              c[0]="cmd.exe"; c[1]="/c" ; c[2]="javac Hello.java";
              Process p=Runtime.getRuntime().exec(c);
              // or Runtime.getRuntime().exec("javac Hello.java");

  • How can I insert a completed file into another PDF file I am developing?

    How can I insert a completed file into another PDF file I am developing?

    Please refer : http://acrobatusers.com/tutorials/how-to-insert-a-pdf-into-a-pdf

  • Copy one text file to another text file and delete last line

    Hi all wonder if someone can help, i want to be able to copy one text file to another text file and remove the last line of the first text file. So currently i have this method:
    Writer output = null;
             File file = new File("playerData.xml");
             try {
                   output = new BufferedWriter(new FileWriter(file, true));
                   output.write("\t" + "<player>" + "\n");
                   output.write("\t" + "\t" + "<playerName>" + playerName + "</playerName>" + "\n");
                   output.write("\t" + "\t" + "<playerScore>" + pointCount + "</playerScore>" + "\n");
                   output.write("\t" + "\t" + "<playerTime>" + minutes + " minutes " + seconds + " seconds" + "</playerTime>" + "\n");
                   output.write("\t" + "</player>" + "\n");
                   output.write("</indianaTuxPlayer>" + "\n");
                  output.close();
                  System.out.println("Player data saved!");
             catch (IOException e) {
                   e.printStackTrace();
              }However each time the method is run i get the "</indianaTuxPlayer>" line repeated, now when i come to read this in as a java file i get errors becuase its not well formed. So my idea is to copy the original file, remove the last line of that file, so the </indianaTuxPlayer> line and then add this to a new file with the next data saved in it. So i would end up with something like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <indianaTuxPlayers>
         <player>
              <playerName>Default Player</playerName>
              <playerScore>0</playerScore>
              <playerTime>null minutes null seconds</playerTime>
         </player>
         <player>
              <playerName>Default Player</playerName>
              <playerScore>0</playerScore>
              <playerTime>null minutes null seconds</playerTime>
         </player>
         <player>
              <playerName>Default Player</playerName>
              <playerScore>0</playerScore>
              <playerTime>null minutes null seconds</playerTime>
         </player>
    </indianaTuxPlayers>
    However after all day searching the internet and trying ways, i have been unable to get anything working, could anyone give me a hand please?

    I would go the XML route too, but for fun, open a file as a BufferedWriter and do this:
    void copyAllButLastLine(File src, BufferedWriter tgt) throws IOException {
        BufferedReader in = new BufferedReader(new FileReader(src));
        try {
            String previous= in.readLine();
            for (String current = null; (current = in.readLine()) != null; previous=current) {
                tgt.write(previous);
                tgt.newLine();
        } finally {
            in.close();
    }

  • Pages Importing from pages file to another pages file

    Is it possible to Import from a separate pages file to another pages file
    IF so HOW?????

    Tulse, I'm using Pages 2 too. The first thing I'd tried this on had only a simple drop cap in a text box, fixed on page. That didn't copy - or at any rate didn't paste. The text box had been sent back to overlay it with inline spaces to clear the capital. These reproduced, but the capital didn't. Neither did kerning or baseline adjustments, nor my inserted guides for "leading" the text to the same depth on every page
    Also page set-up details were not transferred in this way: i.e., if you change the margins in a template (even the blank one) the margins don't transfer. Logical enough, page set-up belongs to the document, not the section.
    Looking at this again, in the Extreme Newsletter template, imported graphics transferred, and inserted text transferred, but layering and placement information did not. I'd made my own pages by altering this, generally using text boxes or shapes to compose picture pages rather than using those in the template. But the copied and pasted sections were all over the place.
    So it may be the case that if you're copying from a section to a document with identical layout, page set-up & etc. to the one you're copying from, the result will contain most of the content. But the layering, placement on page of fixed objects, etc., would seem to be decidedly iffy.
    I've tried it on title page sections, where the info in fixed text boxes copied, but neither their placement nor relative placement, and (in the newsletter template) with both my own and the provided sections, with no consistent results. If it works in some cases, then that would be handy.
    It's easy enough to try, and undo if it doesn't work.
    But it's certainly no subsitute for being able to insert one Pages document into another; nor even always bits of it. I'd be inclined to conclude that copying and pasting in this way uses something less than the full Pages file format.
    Cheers.
    iBook G4   Mac OS X (10.4.7)  

  • Insert pdf file into another pdf file keeps getting stuck

    I am trying to insert a 5 page pdf file into another pdf file (both unsecured) and it keeps getting stuck at about 71%* conplete. I can't even get the file to show up on the screen so i can close it. Help?

    I have tried several different files, and get the same phenomenon with each one –
    1.     I open an acrobat file.
    2.     I open a WORD file.
    3.     I copy a sentence from WORD to the clipboard.
    4.     I click on View in Acrobat, Tools, Pages, other options, insert from clipboard.
    5.     Acrobat shows that it is copying, and when it gets to 67% it stops and runs and runs and then only way I can stop it is to go to the task manager and end task.
    I tried refrying with a file and that didn’t work, and I can’t imagine that Acrobat was designed so that each time I try to insert from WORD I would have to refry (even if it did work).
    Please help!
    Thank you
    Shirah
    Moadim LeSimcha, times of joy!

  • ANT - Jar File include another Jar file and importing classes

    Here is the directory structure i have set up:
    FTPGetter
      \src
        \com
          \abc
            \ftpgetter
              - GUI.java
              - FTPGetter.java
              - Login.java
      \classes
      \include
        - ftpClient.jar
        - info.xml
      \jar
        - FTPGetter.jarThe code compiles file and can create a Jar file without errors. But when I execute the Jar file, I get
    java.lang.NoClassDefFoundError: com/abc/ftpclient/FTPwhich is a class that I import from the ftpClient.jar file in FTPGetter.java
    What gives?
    Here is my necessary build.xml code:
    <?xml version="1.0"?>
    <project name="FTPGetter" default="all">
      <property name="src.dir"        value="src"/>
      <property name="package.name"   value="com.abc.ftpgetter"/>
      <property name="package.dir"    value="${src.dir}/com/abc/ftpgetter"/>
      <property name="classes.dir"    value="classes"/>
      <property name="include.dir"    value="include"/>
      <property name="jar.dir"        value="jar"/>
      <property name="javadoc.dir"    value="docs"/>
      <property name="javadoc.title"  value="FTPGetter"/>
      <property name="javadoc.header" value="FTPGetter - By ABC XYZ [2005]"/>
      <property name="run.classname"  value="${package.name}.FTPGetter"/>
      <target name="init">
        <mkdir dir="${javadoc.dir}" />
        <mkdir dir="${classes.dir}" />
        <mkdir dir="${jar.dir}" />
      </target>
      <target name="all" depends ="compile,jar" />
      <target name="compile" description="Compile Java code" depends="clean, init">
        <javac srcdir="${package.dir}" destdir="${classes.dir}">
          <classpath>
            <!-- use the value of the ${classes.dir} property in the classpath -->
            <pathelement path="${classes.dir}" />
            <!-- include all jar files  -->
            <fileset dir="${include.dir}">
              <include name="**/*.jar"/>
            </fileset>
          </classpath>
        </javac>
      </target>
      <target name="clean" description="Clean up">
        <delete dir="${javadoc.dir}" />
        <delete dir="${classes.dir}" />
        <delete dir="${jar.dir}" />
      </target>
      <target name="jar" depends="compile">
        <jar jarfile="${jar.dir}/FTPGetter.jar" update="false">
          <fileset dir="${classes.dir}" includes="**/*.class" />
    <!-- Include xml file to read.-->
          <fileset dir="${include.dir}" includes="info.xml" />
    <!-- Include ftpClient in the jar file.-->
          <fileset dir="${include.dir}" includes="ftpClient.jar" />
          <manifest>
            <attribute name="Main-Class" value="com.abc.ftpgetter.FTPGetter" />
            <attribute name="Class-Path" value="include/ftpClient.jar"/>
          </manifest>
        </jar>
      </target>
    </project>

    nevermind I got that fixed now:
    had to get the build.xml code for the <target name="jar" depends="compile">so that it looks more like:
      <target name="jar" depends="compile">
        <jar jarfile="${jar.dir}/FTPGetter.jar">
          <zipfileset dir="classes" prefix="" />
          <zipfileset src="include/ftpClient.jar" />
          <zipfileset dir="${include.dir}" includes="info.xml" />
          <manifest>
            <attribute name="Main-Class" value="com.abc.ftpgetter.FTPGetter" />
          </manifest>
        </jar>
      </target>Keyword would need to be zipfileset.

  • Import location in wsit-client.xml to file in another jar

    Normally the wsit-client.xml has import statements like this:
    +<import location="foo.xml" namespace="http://foo.org/" />+
    I've found that their can be online 1 wsit-client.xml on the classpath/META-INF, but can I refer to an xml who's located into another jar in that wsit-client.xml? Something like :
    +<import location="classPathResource/WEB-INF/foo.xml" namespace="http://foo.org/" />+
    I would like to create a single wsit-client.xml who contains the imports for all my webservices but I want to separate the configuration for all the different webservices in to different projects.

    ApplicationClientInitialcontextFactory class is generally used with thick clients [A java swing client.] The client is bundled as a jar and application-client.xml is placed under the META-INF of the archive.
    For JSP clients you can try using com.evermind.server.rmi.RMIInitialcontextFactory to lookup the beans.
    [You can also tty placing the application-client.xml under a META-INF folder in the deployed JSP application root folder eg: j2ee/home/applications/MyApp/META-INF/application-client.xml]
    hope that helps
    IDC_OTN,
    Neelesh

  • Setting Classpath so one jar can access another jar

    I am having trouble with running an application as a jar that accesses other custom libraries.
    I have made a small example to try to get this working.
    I have
         HelloWorld.class - that prints out "HelloWorld" and then throws a custom exception JWIException
         JWIException - exception that is in a package com.jeffersonwells.util
    I have put the JWIException class in the directory D:\apps\jbin\com\jeffersonwells\util.
    I have a manifest file that looks like the following.
         Manifest-Version: 1.0
         Main-Class: HelloWorld
         Class-Path: "d:\apps\jbin\"
    I have created a jar with the manifest file and the HelloWorld class
    When I run the jar, I get the following
         Exception in thread "main" java.lang.NoClassDefFoundError: com/jeffersonwells/util/JWIException
    So, I believe the classpath is not being set correctly.
    Then the second part would be to get the HelloWorld app to access the JWIException in another jar file instead of in the directory structure. I assume if the first scenario gets working, this will be fixed as well.
    I would greatly appreciate any assistance you can provide.
    Thanks,
    Tom Krueger

    I thank you all very much. The problem I was having was with not having relative paths in my Class-Path.
    Having the relative paths will work for the most part, however, sometimes we may want to move the executable jar to a different location. Does anyone have a great solution taking the following into consideration.
    Previous posts have said you can reference classpaths through http or ftp. Great, however if you set this to your http://domain/whatever I'm assuming this will prohibit you from moving the application from dev to test to production without modifying the url.
    Thanks for any thoughts!!
    P.S.
    I'm also in a battle here whether to jar libraries or not. jaring allows you to easily move them from server to server and more importantly for me determine versions of compatible files. However, the argument against jaring is speed of development, why jar if I can pull up a java file compile it and copy it to the server. Why waste time in the whole jaring process.
    Thanks again!!!

  • Calling a thread from a cvi code file to another code file

                Hello, 
                I want to call a thread from a labwindows/cvi code file to another labwindows/cvi code file. Namely, my thread function (GraphLoop) is in 'TestsModel.c' ; but I will call the thread in 'Tests.c' .  My code in 'Tests.c' is in the following;
    int CVICALLBACK GraphLoop (void *functionData);
    int GraphLoopId;
    int callbackDataGraphLoop;
    int CVICALLBACK CBBasla (int panel, int control, int event,
    void *callbackData, int eventData1, int eventData2)
    switch (event)
    case EVENT_COMMIT:
    CmtInstallThreadPoolCallback (poolHandle, EVENT_TP_THREAD_BEGIN, GraphLoop, callbackDataGraphLoop, GraphLoopId);
    if (tiklandiE3631ACihazinaBaglan == 0 && tiklandi34401ACihazinaBaglan == 0) // 'E3631A Cihazına Bağlan' ve '34401A Cihazına Bağlan' tuşlarına basılmamışsa uyarı verir.
    MessagePopup ("Uyarı", "Lütfen cihaz bağlantısını kontrol ediniz.");
    else
    if (tiklandiKaydet == 0)
    MessagePopup ("Uyarı", "Lütfen ayarları kaydediniz.");
    else
    SetCtrlAttribute (Testler, PnlTestler_BASLA, ATTR_DIMMED, 1); // 'Başla' tuşunu pasif hale getirir.
    SetCtrlAttribute (Testler, PnlTestler_BASLA, ATTR_DISABLE_PANEL_THEME, 1); // 'Başla' tuşunun etiketini pasif hale getirir.
    SetCtrlAttribute (Testler, PnlTestler_BITIR, ATTR_DIMMED, 0); // 'Bitir' tuşunu aktif hale getirir.
    SetCtrlAttribute (Testler, PnlTestler_BITIR, ATTR_DISABLE_PANEL_THEME, 0); // 'Bitir' tuşunun etiketini aktif hale getirir.
    CmtNewThreadPool (DEFAULT_THREAD_POOL_HANDLE, &poolHandle); //Yeni bir thread oluşturur.
    CmtScheduleThreadPoolFunction (poolHandle, GraphLoop, NULL, &GraphLoopId); // GrapLoop thread fonksiyonunu başlatır.
    break;
    case EVENT_RIGHT_CLICK:
    break;
    return 0;
              I take that errror after executing this code;
      error:Undefined symbol '_GraphLoop' referenced in "f:\Tests.obj"
             Please, can you help me for my question?
             Regards...

    Hello Eren,
    I assume this is a link error.
    Do you have TestsModel.c file included in your project?
    Constantin.

Maybe you are looking for