Creating Java Libraries (jar)

Can anybody out there help me with java class archiving? I previously created classes and I want it to be archived in a one jar file, I was able to do the jarring of these files, the problem is I cannot access the library inside this archive from another Java program.
Heres What I Did.
========================
File1: One.java
package abc.util;
public class One{
==========================
File2: Two.java
package abc.util;
public class Two{
============================
I compiled these files, and it created abc/util/One.class and abc/util/Two.class
I Made a jar file by invoking
jar cvf MyJarFile.jar abc
================================================
I used this archive into another java application
import abc.util.*;
public class Test{
public Test(){
One o = new One(); <---- {I got an error here,  "Bad Class" JBuilder Error}
================================================
End of the Story :-)
================================================
Ur help is very much appreciated, thanks!

Here's an example that may help. If I have a jar located at
C:/myworkspace/deploy/utils.jar
Then in order for a java program to import classes from that jar, I need that to be in my CLASSPATH variable.
Such as
CLASSPATH=.;C:/myworkspace/deploy/utils.jar
That's for running the program with javac. For compiling in JBuilder, I use Eclipse, but I'm sure in JBuilder there's something like "libraries" where you list the jar files for JBuilder to search through when you import.
Message was edited by:
Michael_Ebbert

Similar Messages

  • Problem in Creating a jar file using java.util.jar and deploying in jboss 4

    Dear Techies,
    I am facing this peculiar problem. I am creating a jar file programmatically using java.util.jar api. The jar file is created but Jboss AS is unable to deploy this jar file. I have also tested that my created jar file contains the same files. When I create a jar file from the command using jar -cvf command, Jboss is able to deploy. I am sending the code , please review it and let me know the problem. I badly require your help. I am unable to proceeed in this regard. Please help me.
    package com.rrs.corona.solutionsacceleratorstudio.solutionadapter;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.jar.JarEntry;
    import java.util.jar.JarOutputStream;
    import java.util.jar.Manifest;
    import com.rrs.corona.solutionsacceleratorstudio.SASConstants;
    * @author Piku Mishra
    public class JarCreation
         * File object
         File file;
         * JarOutputStream object to create a jar file
         JarOutputStream jarOutput ;
         * File of the generated jar file
         String jarFileName = "rrs.jar";
         *To create a Manifest.mf file
         Manifest manifest = null;
         //Attributes atr = null;
         * Default Constructor to specify the path and
         * name of the jar file
         * @param destnPath of type String denoting the path of the generated jar file
         public JarCreation(String destnPath)
         {//This constructor initializes the destination path and file name of the jar file
              try
                   manifest = new Manifest();
                   jarOutput = new JarOutputStream(new FileOutputStream(destnPath+"/"+jarFileName),manifest);
              catch(Exception e)
                   e.printStackTrace();
         public JarCreation()
         * This method is used to obtain the list of files present in a
         * directory
         * @param path of type String specifying the path of directory containing the files
         * @return the list of files from a particular directory
         public File[] getFiles(String path)
         {//This method is used to obtain the list of files in a directory
              try
                   file = new File(path);
              catch(Exception e)
                   e.printStackTrace();
              return file.listFiles();
         * This method is used to create a jar file from a directory
         * @param path of type String specifying the directory to make jar
         public void createJar(String path)
         {//This method is used to create a jar file from
              // a directory. If the directory contains several nested directory
              //it will work.
              try
                   byte[] buff = new byte[2048];
                   File[] fileList = getFiles(path);
                   for(int i=0;i<fileList.length;i++)
                        if(fileList.isDirectory())
                             createJar(fileList[i].getAbsolutePath());//Recusive method to get the files
                        else
                             FileInputStream fin = new FileInputStream(fileList[i]);
                             String temp = fileList[i].getAbsolutePath();
                             String subTemp = temp.substring(temp.indexOf("bin")+4,temp.length());
    //                         System.out.println( subTemp+":"+fin.getChannel().size());
                             jarOutput.putNextEntry(new JarEntry(subTemp));
                             int len ;
                             while((len=fin.read(buff))>0)
                                  jarOutput.write(buff,0,len);
                             fin.close();
              catch( Exception e )
                   e.printStackTrace();
         * Method used to close the object for JarOutputStream
         public void close()
         {//This method is used to close the
              //JarOutputStream
              try
                   jarOutput.flush();
                   jarOutput.close();
              catch(Exception e)
                   e.printStackTrace();
         public static void main( String[] args )
              JarCreation jarCreate = new JarCreation("destnation path where jar file will be created /");
              jarCreate.createJar("put your source directory");
              jarCreate.close();

    Hi,
    I have gone through your code and the problem is that when you create jar it takes a complete path address (which is called using getAbsolutePath ) (when you extract you see the path; C:\..\...\..\ )
    You need to truncate this complete path and take only the path address where your files are stored and the problem must be solved.

  • Installation hangs on 'createing java jar files' section

    Hi,
    On installtion of JRE 1.4, on a new Win98 installation, the installation hangs at the point, "Creating java JAR files". Any ideas on the reason for this hanging
    Regards.

    I had this same problem under Windos XP. Solved when I turned off my Norton Antivirus. It went away, and installation completed

  • How to create java archive using jar command

    hello
    what is the syntax for creating java acrchive using jar command line
    jar -c ???????
    urgent plzz

    jar cf myjar.jar classfiles...
    If you have a manifest file you want to add:
    jar cfm myjar.jar manifest.mf classfiles...
    Also check the documentation:
    http://java.sun.com/j2se/1.3/docs/tooldocs/tools.html
    You can find a link to jar there.

  • Creating an exacutable jar file in netbeans

    Hey, how can i create an exacutable jar file in netbeans ?

    i guess you already have a project created, if you don't create a new java application project.
    Then you need to do the following:
    1. Set the main class. This is the class that will run first.
    for this you need to right click in the project node, select properties, then run and in the Main Class field put the main class.
    2. Set the classpath: you need to put all the libraries or resources you use in your project.
    to do that right click the libraries node, select properties, then add library and add all the libraries that your project needs
    by doing this steps netbeans will create your manifest file and the jar that will create will be executable.
    Hope this helps.
    Escobar5

  • Creating War , not Jar file.

    I am trying to create my EJB and i created my web project. The problem seems that my JBoss will not recognize and deploy my table perhaps due to the structure of the war file.
    My entities are working perfectly as they work, and have already been tested.
    ANyway, what i want is some help into getting my build.xml into making a jar file and sending that one instead of the the war file..
    Can someone please let me a link of where i should look ? Or what i should include in the xml file in order to create the file
    sTevoo.
    P.s - I am using netbeans 6
    Ps - I wasnt sure if i had to post here or in the Deploying - Java Archive (JAR) Files

      <property name="jboss.deploy.dir" value="/home/stevoo/jboss-4.2.2.GA/server/default/deploy"/>
        <property name="librarydir" value="${basedir}/lib"/>
        <property name="src.dir" value="src"/>
        <property name="build.dir" value="build"/>
        <property name="dist.dir" value="dist"/>
        <property name="bin.dir" value="bin"/>
        <target name="prepare">
            <delete dir="${bin.dir}"/>
            <mkdir dir="${bin.dir}"/> 
            <mkdir dir="${bin.dir}/META-INF"/>
        </target>
        <!--Set Libs-->
        <path id="libraries">
            <fileset dir="${librarydir}">
                <include name="*.jar"/>
                <include name="*.zip"/>
            </fileset>
        </path>
        <target name="compile1" depends="prepare">
            <javac srcdir="${src.dir}" destdir="${bin.dir}">
                <classpath refid="libraries"/>
            </javac>
            <echo message="Compile ...." />
        </target>
        <target name="compile" depends="compile1">
            <copy file="${src.dir}/conf/log4j.properties" todir="${bin.dir}/META-INF/"/>
            <copy file="${src.dir}/conf/MANIFEST.MF" todir="${bin.dir}/META-INF/"/> 
            <copy file="${src.dir}/conf/persistence.xml" todir="${bin.dir}/META-INF/"/>
            <jar basedir="${bin.dir}" destfile="${dist.dir}/test.jar"/>
            <echo message="Build...." />
        </target>
        <target name="run" depends="compile">
            <copy file="${dist.dir}/test.jar" todir="${jboss.deploy.dir}"/> 
            <echo message="Run ... ${jboss.deploy.dir}"/>
        </target>
        After a whole day of changing and tweaking and all .... this sort of works.
    Some more tweakong and done.
    Just in case any one else wants this,,,

  • Importing third-party java libraries

    I have just downloaded jakarta httpclient and am trying to get it to work with a program I am writing. Are there instructions somewhere on importing third-party libraries? I've searched these forums, the tutorials, and even google and haven't found any. Or can someone just tell me how to do it?
    Basically I have a folder with a list of java files. I run javac program.java to compile and then java program. The one thing I have seen in these forums is about setting the classpath, but no specifics on what to set it to. Basically I have a folder with the source called java. The only subfolder there is org, the next subfolder is apache, next is commons, then httpcliet, and then all the actual java files with a few other folders with the java files in them. It gives examples in the folder src which is the parent of java. In src there is a folder called examples. The relevent import statements are:
    import org.apache.commons.httpclient.HttpClient;
    import org.apache.commons.httpclient.MultiThreadedHttpConnectionManager;
    import org.apache.commons.httpclient.methods.GetMethod;These are all valid files under the folder system, yet it gives me the error : package org.apache.commons.httpclient does not exist for the first 2 and package org.apache.commons.httpclient.methods does not exist.
    There are also errors resulting from it not recognizing the import statements. Can someone help me please?

    I had a choice between source and binary, if I
    download the binary, should I put the jar file inthe
    folder with the rest of my *.java files?You can, but I'd advise against it because it gets
    messy and confusing.
    Or do I have
    to put the whole folder (with the API, liscense,
    readme, etc. in it) in the same folder as MY codeor
    do I just need the .jar file? You just need the jar file. Don't unpack the jar
    file; the standard java libraries know how to deal
    with a jar file just fine.
    More-or-less standard practice would be to create a
    directory hierarchy like this:
    project_name/
    project_name/lib/
    project_name/src/
    project_name/classes/
    Put the jar files in project_name/lib. Put your java
    source files (the ones that you're creating) into
    src/, and when you compile, put the compiled class
    files into classes/ (use the -d option to javac to do
    that). When you compile and run, include both the
    classes/ directory and the jar files (note: NOT the
    lib/ directory, specify the individual .jar files) in
    the classpath.So do I need the absolute path of the .jar file? If I were to put it in the same folder as my source could I just specify as
    javac -classpath whateverjar.jar MyFile.java
    or do I have to do javac -classpath C:\my folder\my other folder\etc\projectName\lib\whateverjar.jar MyFile.java?
    Thanks

  • Cannot compile Java files or create Java Project

    Hi,
    I cannot compile java files and also didn't see any option
    for creating java project using flex 2 builder.
    Actually am trying to create a FDS project with an option to
    compile on the server. I am using Weblogic 8.1 SP5 as my server.
    thank you
    sun

    hi
    this is may jvm.config file. Can anyone tell me if it is
    right because all the fields are blank.
    # VM configuration
    # Where to find JVM, if {java.home}/jre exists then that JVM
    is used
    # if not then it must be the path to the JRE itself
    # If no java.home is specified a VM is located by looking in
    these places in this
    # order:
    # 1) JAVA_HOME environment variables (same rules as java.home
    above)
    # 2) bin directory for java.dll (windows) or
    lib/<ARCH>/libjava.so (unix)
    # 3) ../jre
    # 4) registry (windows only)
    java.home=C:\Adobe\Flex Builder 2.0 Beta 3\Flex SDK 2.0\jre
    # Arguments to VM
    java.args=-ea -Xmx384m
    # Environment variables we care about, whitespace-separated
    env=
    # java.class.path - use this for adding individual jars or
    # directories. When directories are included they will be
    searched
    # for jars and zips and they will be added to the classpath
    (in
    # addition to the directory itself), the jar to be used in
    launching
    # will be appended to this classpath
    java.class.path=C:\Adobe\Flex Builder 2.0 Beta 3\Flex SDK
    2.0\jre
    # where to find shared libraries, again use commas to
    separate entries
    java.library.path=
    thanks
    sun

  • Loadjava fails; create java source succeeds

    When using loadjava to load a Java class into the database I receive the following error:
    C:\OEMNT\bin>loadjava -user us/pw@db -verbose -resolve HelloWorld.class
    initialization complete
    loading : HelloWorld
    Error while loading HelloWorld
    ORA-00942: table or view does not exist
    creating : HelloWorld
    Error while creating class HelloWorld
    ORA-29506: invalid query derived from USING clause
    ORA-00942: table or view does not exist
    resolver :
    resolving: HelloWorld
    Error while resolving class HelloWorld
    ORA-04043: object HelloWorld does not exist
    loadjava: 3 errors
    When using the CREATE JAVA SOURCE command from SQL the Java source + Class is created without problems.
    It seems loadjava wants to insert or check something in a table. But what table?

    Hi,
    Omitting -jarasresource is the first step.
    You probably need to specify -recursivejars in cas there are jars in your jars.
    Also use -genmissing option in case some classes are still missing in the jars files you've loaded.
    Kuassi http://db360.blogspot.com

  • Error when trying to create a types jar from a web service WSDL

    Hi,
    I generated a WSDL from a web service. When I try to generate a types jar from that WSDL in another project, I get an error:
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    com.bea.workshop.webservices.servicecontrol.ui.except.TypeGenerationFailedException: Buildfile: C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml
    Trying to override old definition of task wsgen
    build:
    build-types:
    clean-types:
    [echo] Deleting types directory c:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474
    [echo] Deleting types jar C:\eclipsews\AAATest\WebContent\WEB-INF\lib\CaregiverEBillingMasterServiceServiceTypes_xmlbeans_apache.jar
    [mkdir] Created dir: C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474
    generate-src-code:
    [echo] Generating types of family xmlbeans_apache from WSDL at file:/C:/eclipsews/AAATest/src/test/CaregiverEBillingMasterServiceService.wsdl, all services. Outputting to c:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474
    [typesGen] Generating complex Java types for schema types in WSDL file:/C:/eclipsews/AAATest/src/test/CaregiverEBillingMasterServiceService.wsdl. Outputting to C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474 ...
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfTreatmentDetailItem@http://org/abc/claims/caregiver/ebilling/services
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfDocumentTypeAutoPayWrapper_literal@java:org.abc.claims.caregiver.ebilling.services.util
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfJavaLangint_literal@java:org.abc.claims.caregiver.ebilling.services
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfDocumentSubmissionHierarchy@http://org/abc/claims/caregiver/ebilling/services
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfMessageCode@http://org/abc/claims/caregiver/ebilling/services
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfFeeCodeType@http://org/abc/claims/caregiver/ebilling/services
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfBatchMessage@http://org/abc/claims/caregiver/ebilling/services
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfArrayOfJavaLangstring_literal@java:org.abc.claims.caregiver.ebilling.services.util
    [typesGen] [WARNING] Generating array which is non-compliant with JaxRPC 1.1 for XML name: t=ArrayOfJavaLangstring_literal@java:org.abc.claims.caregiver.ebilling.services.util
    compile-src-code:
    [echo] Compiling source files from c:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474 to c:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474
    [javac] Compiling 298 source files to C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474
    [javac] ----------
    [javac] 1. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\com\abc\claims\caregiver\ebilling\FeeCodeDocument.java (at line 51)
    [javac]      public static com.abc.claims.caregiver.ebilling.FeeCodeDocument parse(java.lang.String xmlAsString) throws org.apache.xmlbeans.XmlException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 2. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\com\abc\claims\caregiver\ebilling\FeeCodeDocument.java (at line 54)
    [javac]      public static com.abc.claims.caregiver.ebilling.FeeCodeDocument parse(java.lang.String xmlAsString, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 3. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\com\abc\claims\caregiver\ebilling\FeeCodeDocument.java (at line 58)
    [javac]      public static com.abc.claims.caregiver.ebilling.FeeCodeDocument parse(java.io.File file) throws org.apache.xmlbeans.XmlException, java.io.IOException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 4. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\com\abc\claims\caregiver\ebilling\FeeCodeDocument.java (at line 61)
    [javac]      public static com.abc.claims.caregiver.ebilling.FeeCodeDocument parse(java.io.File file, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 5. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\com\abc\claims\caregiver\ebilling\FeeCodeDocument.java (at line 64)
    [javac]      public static com.abc.claims.caregiver.ebilling.FeeCodeDocument parse(java.net.URL u) throws org.apache.xmlbeans.XmlException, java.io.IOException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 6. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\com\abc\claims\caregiver\ebilling\FeeCodeDocument.java (at line 67)
    [javac]      public static com.abc.claims.caregiver.ebilling.FeeCodeDocument parse(java.net.URL u, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, java.io.IOException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    === snipped here due to huge file size ===
    [javac] 2680. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\org\xfa\schema\xfaData\x10\SignatureDocument.java (at line 99)
    [javac]      public static org.xfa.schema.xfaData.x10.SignatureDocument parse(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 2681. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\org\xfa\schema\xfaData\x10\SignatureDocument.java (at line 103)
    [javac]      public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 2682. ERROR in C:\development\wlwBuild\XCaregiverEBillingMasterServiceService1297810259474\org\xfa\schema\xfaData\x10\SignatureDocument.java (at line 107)
    [javac]      public static org.apache.xmlbeans.xml.stream.XMLInputStream newValidatingXMLInputStream(org.apache.xmlbeans.xml.stream.XMLInputStream xis, org.apache.xmlbeans.XmlOptions options) throws org.apache.xmlbeans.XmlException, org.apache.xmlbeans.xml.stream.XMLStreamException {
    [javac]      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    [javac] No exception of type XmlException can be thrown; an exception type must be a subclass of Throwable
    [javac] ----------
    [javac] 2682 problems (2682 errors)
    BUILD FAILED
    C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml:73: The following error occurred while executing this line:
    C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml:107: The following error occurred while executing this line:
    C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml:181: Compile failed; see the compiler error output for details.
    Total time: 17 seconds
         at com.bea.workshop.webservices.servicecontrol.ui.util.TypesGenerationScript.run(TypesGenerationScript.java:197)
         at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:113)
    Caused by: org.eclipse.core.runtime.CoreException: C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml:73: The following error occurred while executing this line:
    C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml:107: The following error occurred while executing this line:
    C:\eclipsews\.metadata\com.bea.workshop.webservices.servicecontrol.ui\build-dir\build.xml:181: Compile failed; see the compiler error output for details.
         at org.eclipse.ant.core.AntRunner.handleInvocationTargetException(AntRunner.java:451)
         at org.eclipse.ant.core.AntRunner.run(AntRunner.java:383)
         at com.bea.workshop.webservices.servicecontrol.ui.util.TypesGenerationScript.run(TypesGenerationScript.java:185)
         ... 1 more
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    I was previously able to generate a types jar just fine from the web service's WSDL. Recently, I made some changes to the web service. Apparently, these changes to the web service now cause the WSDL to be unparseable when trying to generate types jars.
    Any ideas?

    The WSDL is generated from my web service. I made heavy revisions to my web service which, in turn, affected the resultant WSDL. The changes I made to my web service were almost exclusively related to object substitution. For example, prior to the change I was referencing object A from my web service; after the change, I was referencing object B. The objects that I'm referring to are XMLBeans, if that matters. I can't really describe it more than that without actually showing you the WSDL.
    I would post the WSDL file here to allow you to try to create a types jar out of it, but the WSDL exceeds the 30000 character limit for this field. There is no way for me to attach the WSDL to this post.

  • How do I create an executable JAR File ?

    Hi,
    Let's say I have several Class Files that perform a special task.
    How do I bundle them in a JAR file and make it executable, so that the user simply types "prog.jar" and is happy.
    I wonder how that works, as I have to tell the starting point for execution.
    Does anybody now ?
    cu
    Oliver

    Three importants things to do :
    - don't forget to indicate in your manifest.mf the main class and the pacckage
    ex:
    Manifest-Version: 1.0
    Main-Class: mypackage.MyMainClass
    Created-By: 1.3.0 (Sun Microsystems Inc.)
    - don't forget to associate the .jar file with the application java.exe -jar -classpath %CLASSPATH%
    - don't forget to set the environment CLASSPATH correctly
    Hope this help
    Jean

  • How to Include libraries (Jar's/Packages/ClassNotFoundException/Classpath)

    Ive spent hours looking for a solution, So maby i making a simple human error which i cant find.
    Im unfamiliar with using packages.
    I have created a program that use the JDBC libary. However i need to distribute this program and keep getting a ClassNotFoundException which is throw by:
    String s = "com.mysql.jdbc.Driver";
    Class.forName(s);I would like to have the "mysql-connector-java-bin.jar" file inside my main jar file However I think this may be very complex so i assume it would be easier to have it in the same directory as the main jar file.
    I create my main jar file with:
    jar cmf mainClass.txt Main.jar *.class mysql-connector-java-bin.jarI also jarsigner but i wouldn't expect this to case this problem.
    mainClass.txt
    Main-Class: MyClassFile
    Class-Path: mysql-connector-java-bin.jar
    Sealed: trueAny ideas what im doing wrong? or How i could solve this problem?
    Do i need to write a program which installs the JDBC on their system?
    Is there an easy solution?
    Any advice would be greatly appriacted.
    Thanks,

    ty for the reply
    I now create my jar file with:
    jar cmf mainClass.txt Main.jar *.classand the "mysql-connector-java-bin.jar" is still in same directory as my main.jar file
    Ive also replaced the "mysql-connector-java-bin.jar" to make sure it hasnt been corrupted somehow.
    However i still get the same error.
    the stackTrace is:
    java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)
            at java.lang.Class.forName0(Native Method)
            at java.lang.Class.forName(Unknown Source)
            at SQLConnection.<init>(SQLConnection.java:18)SQLConnection a class i have created.and the lines 17 and 18 are posted in my first post.
    Anyideas?

  • Java to jar, with mainClass (something's wrong)

    Hi. I know, there were some topics, about the java to jar issue, but I think this is different a bit...
    so the question is: I'm trying to make a .jar from my jave file, and I've found a tutorial for it on the net (and as far as I remember, I've used this tutorial before, and it helped)
    it says, I have to use this command:
    "jar cmf mainClass.txt example.jar *.class"
    I have a proper mainClass.txt, but when I try to run this command, I get this error message
    "*.class: no such file or directory"
    what am I doing wrong?
    Thx for any help.

    Hi there,
    As per the documentation you are trying to:
    jar - The basic command
    c - Create a new jar file
    m - With a manifest entry
    f - With the specific archive name
    mainClass.txt - Name of the manifest file
    example.jar - Name of the jar file you are creating
    *.class - Jar up all of the class files that exist in this directory
    So basically you have no class files in hte directory you are running this command from.
    Also you'll probably want to run the command like so:
    jar cmf example.jar mainClass.txt *.class - You'd typically have the name of the manifest file 2nd
    Cheers,
    Martijn

  • Newbie question abount managing java libraries

    Hello all,
    I'm rahter new to Java and have a question about how to manage java libraries in a central location. I've been told to use Maven, but I don't need/want to use it.
    I'm only asking a way to have centralized the different Java libraries that a Developer Team may use in a form that they could download to their PCs and use in their projects, thinking in a free IDE environment where could be JDeveloper, NetBeans and Eclipse in use.
    I'm thinking in use Subversion to upload the different Java libraries files to a Subversion Repository and then each Developer Team doing a checkout of what they need, but I think it's not the primary use to do with the versioning system.
    Please, could somebody point me out if there is any product that could fit my needs about managing Java libraries ?
    Thanks in advance.
    Angel.

    - limit the set of packages to those which have been approved by the processYou can constrain Maven to only use an internal repository from which to pull libraries. If you don't put the libraries in the repository you can't use them in your project.
    - limit the packages by licenseI don't think there's anything built in to do this. There's a space for that information in the pom (metadata) file though, so it would be possible to do so. You'd probably have to do some work on the repository to bring ensure the fields was populated though - I get the impression that it tends not to be by default.
    - produce audit logs of what the dependencies and licenses used by each project isDependencies yes, certainly. Licenses again I don't think there's anything existing but you could probably adapt the dependency plugin to report this.
    Example dependency tree generated by Maven for JA-SIG CAS:
    [INFO] [dependency:tree]
    [INFO] org.jasig.cas:cas-server-webapp:war:3.2.1
    [INFO] +- log4j:log4j:jar:1.2.15:runtime
    [INFO] +- net.sf.ehcache:ehcache:jar:1.4.0-beta2:runtime
    [INFO] |  +- net.sf.jsr107cache:jsr107cache:jar:1.0:runtime
    [INFO] |  \- backport-util-concurrent:backport-util-concurrent:jar:3.0:runtime
    [INFO] +- commons-lang:commons-lang:jar:2.2:runtime (scope not updated to compile)
    [INFO] +- quartz:quartz:jar:1.5.2:compile
    [INFO] +- org.springframework.ldap:spring-ldap:jar:1.2.1:compile
    [INFO] +- org.springframework.ldap:spring-ldap-tiger:jar:1.2.1:compile
    [INFO] +- org.springframework:spring-webmvc:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-beans:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-context:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-context-support:jar:2.5.1:compile
    [INFO] |  +- org.springframework:spring-core:jar:2.5.1:compile
    [INFO] |  \- org.springframework:spring-web:jar:2.5.1:compile
    [INFO] +- javax.servlet:jstl:jar:1.1.2:compile
    [INFO] +- javax.servlet:servlet-api:jar:2.4:provided (scope not updated to compile)
    [INFO] +- ognl:ognl:jar:2.6.9:runtime (scope not updated to compile)
    [INFO] +- junit:junit:jar:3.8.1:test
    [INFO] +- org.acegisecurity:acegi-security:jar:1.0.6:runtime
    [INFO] |  +- commons-codec:commons-codec:jar:1.3:runtime
    [INFO] |  \- oro:oro:jar:2.0.8:runtime
    [INFO] +- cas:casclient:jar:2.1.1:runtime
    [INFO] +- org.springframework:spring-aop:jar:2.5.1:compile
    [INFO] |  \- aopalliance:aopalliance:jar:1.0:compile
    [INFO] +- org.springframework:spring-test:jar:2.5.1:test
    [INFO] +- commons-logging:commons-logging:jar:1.1:compile
    [INFO] +- org.springframework:spring-webflow:jar:1.0.5:compile
    [INFO] |  \- org.springframework:spring-binding:jar:1.0.5:compile
    [INFO] +- org.inspektr:inspektr-core:jar:0.6.1:compile
    [INFO] |  +- aspectj:aspectjweaver:jar:1.5.3:runtime
    [INFO] |  +- aspectj:aspectjrt:jar:1.5.3:compile
    [INFO] |  \- org.springframework:spring-jdbc:jar:1.2.9:compile
    [INFO] |     \- org.springframework:spring-tx:jar:2.5.1:compile
    [INFO] +- org.jasig.cas:cas-server-core:jar:3.2.1:compile
    [INFO] |  +- org.jasig.service:person-directory-impl:jar:1.1.1:compile
    [INFO] |  |  +- org.jasig.service:person-directory-api:jar:1.1.1:compile
    [INFO] |  |  \- commons-collections:commons-collections:jar:3.2:compile
    [INFO] |  +- jdom:jdom:jar:1.0:compile
    [INFO] |  +- org.springframework:spring-orm:jar:2.5.1:compile
    [INFO] |  +- org.apache.santuario:xmlsec:jar:1.4.0:runtime
    [INFO] |  +- org.opensaml:opensaml:jar:1.1b:compile
    [INFO] |  +- javax.persistence:persistence-api:jar:1.0:compile
    [INFO] |  \- javax.xml:xmldsig:jar:1.0:compile
    [INFO] \- taglibs:standard:jar:1.1.2:compile

  • Java.util.zip java.util.jar API usage

    I have been trying unsuccessfully for the past two days to be able to programatically add and extract files into and from a JAR using the API. I haven't found any API docs that cover the basics and I have been stumped using the nuggets that I have found on the Forum so far. Below is the code so far. Feel free to use what works in your programs, but if you find out how to get this to work. Sorry for the long post, but I gather this is a common problem that needs to be solved.
    ___________JAR CLASS_______________
    import java.io.*;
    import java.util.*;
    import java.util.jar.*;
    import java.util.zip.*;
    public class Jar {
        public Jar() {
        public boolean copyToJar(File[] sources, File destination) {
            if (destination == null) {
                return false;
            if (nameContainsWildcards(destination)) {
                return false;
            File[] sourceArray = expandWildcards(sources);
            if (sourceArray == null) {
                System.out.println("sourceArray was empty");
                return false;
              System.out.println("Ready to add " + sourceArray.length + " files to " + destination);
              //variables for copying the old destination file to the new destination
              File tmpFile = null;
              JarFile tmpJarFile = null;
              InputStream jarInput = null;
              JarInputStream jarIn = null;
            InputStreamReader jarDataFile = null;
              //variables for the destination
            OutputStream output = null;
            JarOutputStream jarOut = null;
            File input = null;
            FileInputStream dataFile = null;
            int buf = -1;
              if (destination.exists()) {
                   System.out.println("The destination file exists");
                   //copy the destination to temporary
                   //fix copyToJar to use the same .tmp file name as the destination (for reentrant code)
                   tmpFile = new File(destination.getParent() + "\\" + "jar.tmp");
                   if (tmpFile.exists()) {
                        tmpFile.delete();
                   //rename the original to the TempFile
                   destination.renameTo(tmpFile);
                   if (destination.exists()) {
                        destination.delete();
                   try {
                        tmpJarFile = new JarFile(tmpFile);
                   } catch (IOException ioe) {
                        System.out.println("Exception while creating JarFile " + ioe );
            try {
                   //initialize the destination
                output = new FileOutputStream(destination);
                jarOut = new JarOutputStream(output);
                   //if there is a tmpFile copy contents of tmpFile to the new destination
                   if (tmpFile != null) {
                        jarInput = new FileInputStream(tmpFile);
                        jarIn = new JarInputStream(jarInput);
                        ZipEntry ze = null;
                        boolean contains = false;
                        while((ze = jarIn.getNextEntry()) != null) {
                             System.out.println("Working on zipEntry " + ze.getName());
                             contains = false;
                             for (int i=0; i<sourceArray.length; i++) {
                                  if (ze.getName().compareToIgnoreCase(sourceArray.getName()) == 0) {
                                       contains = true;
                             if (contains == false) {
              jarDataFile = new InputStreamReader(tmpJarFile.getInputStream(ze));
                                  System.out.println("The zip Entry was copied from the old file");
                                  jarOut.putNextEntry(ze);
                                  buf = -1;
                                  buf = jarDataFile.read();
                                  while (buf != -1) {
                                       jarOut.write(buf);
                                       buf = jarDataFile.read();
                                  jarOut.closeEntry();
                                  jarDataFile.close();
                        jarIn.close();
                        jarInput.close();
                        tmpFile.delete();
                        tmpJarFile.close();
                   //copy the new files to the destination
    for (int i=0; i<sourceArray.length; i++) {
    if (sourceArray[i].isDirectory()) {
                             //fix copyToJar to copy entire directory if the directory is given as a source
    } else {
    System.out.println("Adding " + sourceArray[i].getAbsolutePath() + " to "
    + destination.getAbsolutePath());
    dataFile = new FileInputStream(sourceArray[i]);
    ZipEntry entry= new ZipEntry(sourceArray[i].getName());
    jarOut.putNextEntry(entry);
    buf = -1;
    buf = dataFile.read();
    while (buf != -1) {
    jarOut.write(buf);
    buf = dataFile.read();
    jarOut.closeEntry();
    jarOut.close();
    output.close();
    dataFile.close();
    } catch (IOException ioe) {
    System.out.println("Exception " + ioe + " occured while writing the backup jar file.");
    try {
    if (jarOut != null)
    jarOut.close();
    if (output != null)
    output.close();
    if (dataFile != null)
    dataFile.close();
    if (jarInput != null)
    jarInput.close();
    if (jarIn != null)
    jarIn.close();
    } catch (IOException ioe2) {
    System.out.println("Exception " + ioe2 + " closing the jar file.");
    return false;
    return true;
    public boolean copyToJar(File source, File destination) {
    File[] sourceArray = expandWildcards(source);
    if (sourceArray == null) {
    System.out.println("sourceArray was empty");
    return false;
    return copyToJar(sourceArray, destination);
         public boolean extractFromJar(File source, File extract, File destDirectory) {
              try {
                   JarFile jarIn = new JarFile(source);
                   ZipEntry ze = jarIn.getEntry(extract.getName());
                   if (ze == null) {
                        System.out.println("Could not find file " + extract + " in jarFile " + source);
                   } else {
                        JarInputStream jarInput = null;
                        InputStreamReader buf = null;
                        FileOutputStream out = null;
                        InputStream in = jarIn.getInputStream(ze);
                        buf = new InputStreamReader(in);
                        out = new FileOutputStream(extract);
                        int buffer = -1;
                        buffer = buf.read();
                        while (buffer != -1) {
                             out.write(buffer);
                             buffer = buf.read();
              } catch (IOException ioe) {
                   System.out.println("Could not extract the file " + extract + " from jarFile " + source);
                   return false;
              return true;
    public int numberOfLines(File fileToCount) {
    int num = 0;
    try {
    FileReader regRead = new FileReader(fileToCount);
    LineNumberReader regReadLine = new LineNumberReader(regRead);
    while (regReadLine.readLine() != null) {
    num = regReadLine.getLineNumber();
    regRead.close();
    regReadLine.close();
    } catch (IOException ioe) {
    System.out.println("Exception " + ioe + " occured in " + this.getClass().getName());
    return num;
    static public boolean nameContainsWildcards(File source) {
    if (source != null) {
    if ((source.getName().indexOf('*')) >=0) {
    return true;
    //fix this check to look for other wildcards
    return false;
    * Expands the * wildcard that does not start the expression. For example,
    * in a directory whose contents are TEST1.DAT, TEST2.DAT AND TEST3.DAT, this
    * funtion will return the following based on the input
    * Input Returns
    * TEST1.DAT File[] containing the first file
    * TEST*.DAT File[] containing all three files plus any that match TEST*.*
    * T*.* File[] containing all three files plus any that match T*.*
    * *.* File[] containing all three files plus any that match *.*
    * EST.DAT File[] containing no files (not a legal expression...yet)
    * ? or
    public File[] expandWildcards(File source) {
    if (source == null) {
    System.out.println("Cannot expand wildCards for a null File");
    return null;
    File[] sourceArray = null;
    if (nameContainsWildcards(source)) {
    FileFilter wildcardFilter = new WildcardFilter(source.getName());
    File sourceParent = new File(source.getParent());
    if (sourceParent != null) {
    sourceArray = sourceParent.listFiles(wildcardFilter);
    } else {
    sourceArray = new File[1];
    sourceArray[0] = source;
    } else {
    sourceArray = new File[1];
    sourceArray[0] = source;
    return sourceArray;
    public File[] expandWildcards(File[] sources) {
    File[] sourceArray = null;
    List fileArrays = new ArrayList();
    for (int i=0; i< sources.length; i++) {
    fileArrays.add(expandWildcards(sources[i]));
    int totalFiles = 0;
    for (int i=0; i < fileArrays.size(); i++) {
    File[] tmp = (File []) fileArrays.get(i);
    if (tmp != null) {
         //System.out.println("Adding " + tmp.length + " to total files");
         totalFiles += tmp.length;
    System.out.println("totalFiles expanded = " + totalFiles);
    sourceArray = new File[totalFiles];
    int nextIndex = 0;
    for (int i=0; i < fileArrays.size(); i++) {
    File[] tmp = (File []) fileArrays.get(i);
    if (tmp != null) {
                        for(int j=0; j < tmp.length; j++) {
                             //System.out.println("Adding file " + tmp[j] + " to sourceArray");
                             sourceArray[nextIndex] = tmp[j];
                             nextIndex++;
    return sourceArray;
    static public void main(String argv[]) {
    Jar jarRun = new Jar();
    File testFile = new File("D:\\test.jar");
              File testFile1 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultCustomers.jar");
              File testFile2 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultInventory.jar");
              File testFile3 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultVendors.jar");
              File testFile4 = new File("C:\\Program Files\\RBusinessSystems\\Location Sync\\LONGMONT\\LongmontDefaultClerks.jar");
              if (argv.length >= 1) {
                   System.out.println("Creating the Jar File");
                   jarRun.copyToJar(testFile1, testFile);
                   jarRun.copyToJar(testFile2, testFile);
                   jarRun.copyToJar(testFile3, testFile);
                   jarRun.copyToJar(testFile4, testFile);
              } else {
                   System.out.println("Extracting from the Jar File");
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultCustomers.jar"), new File("d:\\"));
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultInventory.jar"), new File("d:\\"));
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultVendors.jar"), new File("d:\\"));
                   jarRun.extractFromJar(testFile, new File("d:\\LongmontDefaultClerks.jar"), new File("d:\\"));
    ______________WILDCARD FILTER CLASS __________
    import java.io.File;
    import java.io.FileFilter;
    public class WildcardFilter implements FileFilter {
        private String compare = null;
        private String wildcardStart = null;
        private String wildcardMiddle = null;
        private String wildcardEnd = null;
        WildcardFilter(String comparison) {
            setCompare(comparison);
        public void setCompare(String comparison) {
            compare = comparison.toLowerCase();
            wildcardStart = null;
            wildcardMiddle = null;
            wildcardEnd = null;
            int index = compare.indexOf('*');
            if (index != -1) {
                wildcardStart = compare.substring(0, index);
                if (index + 1 < compare.length()) {
                    wildcardEnd = compare.substring(index + 1, compare.length());
                System.out.println("Expanding fileNames starting with " + wildcardStart
                          + " and ending with " + wildcardEnd);
        public boolean accept(File check) {
            String checkName = check.getName().toLowerCase();
            if (compare == null) {
                return false;
            if (((wildcardEnd == null) || (wildcardEnd.compareTo("") == 0))
                && ((wildcardStart == null) || (wildcardStart.compareTo("") ==0))) {
                return false;
            if (((wildcardStart == null) || (wildcardStart.compareTo("") ==0))
                && (wildcardEnd != null)) {
                if ((wildcardEnd.compareTo(".*") ==0) || (wildcardEnd.compareTo("*") == 0))
                    return true;
                if (checkName.endsWith(wildcardEnd))
                    return true;
            if (((wildcardEnd == null) || (wildcardEnd.compareTo("") == 0))
                && (wildcardStart != null)) {
                if (checkName.startsWith(wildcardStart))
                    return true;
            if ((checkName.startsWith(wildcardStart))
                && (checkName.endsWith(wildcardEnd))) {
                return true;
            return false;

    I figured it out based on some of the other posts I found on this Forum. Following is the working code. While this code is not as robust as it needs to be for production, it will at least get you started on extracting from jar files and writing to jarfiles.
    import java.io.*;
    import java.util.jar.*;
    import java.util.zip.*;
    //NOTE: You can only copy entries created by the Jar tool
    class JarTest {
        JarTest() {
        public boolean copyToJar(File[] fileList, File jarFile) {
            JarEntry je = null;
            File tmpFile = null;
            FileOutputStream fos = null;
            JarOutputStream jos = null;
            BufferedWriter bw = null;
            FileInputStream fis = null;
            JarInputStream jis = null;
            BufferedReader br = null;
            int buf = -1;
            boolean badZipFile = false;
            boolean refreshFromNewFile = false;
            String tmpFileName = jarFile.getAbsolutePath() + ".tmp";
            try {
                tmpFile = new File(tmpFileName);
                fos = new FileOutputStream(tmpFile);
                jos = new JarOutputStream(fos);
                bw = new BufferedWriter(new OutputStreamWriter(jos));
            } catch (IOException ioe) {
                ioe.printStackTrace();
        if(jarFile.exists()) {
                try {
                    fis = new FileInputStream(jarFile);
                    jis = new JarInputStream(fis);
                    br = new BufferedReader(new InputStreamReader(jis));
                } catch (IOException ioe) {
                    System.out.println(ioe);
                try {
                    while((je = jis.getNextJarEntry()) != null) {
                        refreshFromNewFile = false;
                        for (int i = 0; i < fileList.length; i++) {
                            if (je.getName().compareToIgnoreCase(fileList.getName()) == 0) {
    refreshFromNewFile = true;
    if (refreshFromNewFile) {
    //do nothing so we can add the new file below
    } else {
    jos.putNextEntry(je);
    int index = 0;
    buf = -1;
    while((buf = br.read()) != -1) {
    bw.write(buf);
    index++;
    System.out.println("Copied entry " + je.getName() + " of " + index + " bytes from " + jarFile.getName());
    bw.flush();
    jos.closeEntry();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    badZipFile = true;
    try {
    br.close();
    jis.close();
    fis.close();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    for (int i = 0; i < fileList.length; i++) {
    try {
    fis = new FileInputStream(fileList[i]);
    br = new BufferedReader(new InputStreamReader(fis));
    // write the new entries to the tmpFile
    je = new JarEntry(fileList[i].getName());
    jos.putNextEntry(je);
    int index = 0;
    buf = -1;
    while((buf = br.read()) != -1) {
    bw.write(buf);
    index++;
    bw.flush();
    System.out.println("Added entry " + je.getName() + " of " + index + " bytes.");
    jos.closeEntry();
    } catch (IOException ioe) {
    ioe.printStackTrace();
    badZipFile = true;
    try {
    jos.close();
    if (tmpFile != null) {
    // rename the tmpFile to jarFile
    jarFile.delete();
    tmpFile.renameTo(jarFile);
    } catch (IOException ioe) {
    ioe.printStackTrace();
    return true;
    public boolean extractFromJar(File[] fileList, File jarFile) {
    ZipEntry zen = null;
    BufferedReader br = null;
    FileOutputStream fos = null;
    BufferedWriter bw = null;
    try {
    for (int i = 0; i < fileList.length; i++) {
    JarFile jar = new JarFile(jarFile);
    zen = jar.getEntry(fileList[i].getName());
    if (zen == null) {
    System.out.println("Could not find the file " + fileList[i].getName() + " in the zip file " + jar.getName());
    } else {
    File parentDirectory = new File(fileList[i].getParent());
    parentDirectory.mkdirs();
    InputStream in = jar.getInputStream(zen);
    br = new BufferedReader(new InputStreamReader(in));
    fos = new FileOutputStream(fileList[i]);
    bw = new BufferedWriter(new OutputStreamWriter(fos));
    int buf = -1;
    int index = 0;
    while((buf = br.read()) != -1) {
    bw.write(buf);
    bw.flush();
    index++;
    System.out.println("Extracted file " + fileList[i] + " of " + index + " bytes from " + jarFile);
    br.close();
    bw.close();
    } catch (IOException ioe) {
    System.out.println(ioe);
    return false;
    return true;
    public static void main(String[] argv) {
    JarTest jt = new JarTest();
    File jarFile = new File("d:\\test\\test.zip");
    File[] fileList1 = new File[] {new File("d:\\test\\CustomerRefreshRequest.bat"),
                                            new File("d:\\test\\CustomerUpdateGet.bat"),
                                            new File("d:\\test\\CustomerUpdateRequest.bat"),
                                            new File("d:\\test\\LongmontDefaultClerks.jar"),
                                            new File("d:\\test\\LongmontDefaultCustomers.jar"),
                                            new File("d:\\test\\LongmontDefaultInventory.jar")};
    File[] fileList2 = new File[] { new File("d:\\test\\install.bat"),
    new File("d:\\test\\LongmontDefaultVendors.jar"),
    new File("d:\\test\\CustomerUpdateSend.bat") };
    jt.copyToJar(fileList1, jarFile);
    jt.copyToJar(fileList2, jarFile);
    File[] fileList3 = new File[] {new File("d:\\test\\temp\\CustomerRefreshRequest.bat"),
                                            new File("d:\\test\\temp\\CustomerUpdateGet.bat"),
                                            new File("d:\\test\\temp\\CustomerUpdateRequest.bat"),
                                            new File("d:\\test\\temp\\LongmontDefaultClerks.jar"),
                                            new File("d:\\test\\temp\\LongmontDefaultCustomers.jar"),
                                            new File("d:\\test\\temp\\LongmontDefaultInventory.jar")};
    File[] fileList4 = new File[] { new File("d:\\test\\temp\\INSTALL.BAT"),
    new File("d:\\test\\temp\\LongmontDefaultVendors.jar"),
    new File("d:\\test\\temp\\CustomerUpdateSend.bat") };
    jt.extractFromJar(fileList3, jarFile);
    jt.extractFromJar(fileList4, jarFile);

Maybe you are looking for

  • Purpose of defining account group?

    purpose of defining account group?

  • JDeveloper 10.1.3.3.0.3 Blue Screen of Death on Windows 7 64-bit

    Hi, I am using JDeveloper 10.1.3.3.0.3 on a Windows 7 (64-bit) machine. Whenever I try and use the PgUp or PgDn keys or even use the main vertical scrollbar it produces a Blue Screen of Death. Saying the Video Scheduler has encountered an unexpected

  • Creating a Separate Wireless Network With no Ethernet

    Hello- I am attempting to set-up my Airport Express with my receiver and speakers in order to play music wirelessly. I have successfully done so when I choose "Join an Existing Wireless network", but I have noticed that this bogs down my wi-fi networ

  • Async To Sync

    Hello, using jdev 11.1.1.4 i mistakenly created a Asyc BPEL process. process is ready and working I want to now convert it to sync process, without impacting the functionality. what is the best way to convert async process to sync process ? How do i

  • Transparent background instead of color for stage

    Is there a way to set the background color for the stage to transparent instead of a color? I only see color as options when clicking in property manager for the background.