How to create jar files from my code?

Hi, I�m a rookie programmer and i need to create jar files in my application code. Which classes do i need to use?
Can anybody give me an example?
Thanx in advance

Thanx Uwe. You�re right, i�m only trying to create jar
files (and extract files from a jar file) I will try
what you told me. Anyway, I have some doubts about how
to use those classes.Can you give me any example?
Thanx again!To create jar files use the class JarOutputStream.
Add a ZipEntry for each entry in the jar file.
To read jar files use the class JarInputStream and get all JarEntry.
It should be straight forward.
Uwe

Similar Messages

  • How to create dll file from c code to use in compactrio 9004 RT controller

    Hi.
    I am using Compactrio 9004 Real time controller and i am new to this. I have a C code and i want to use this with the RT controller.I red that that can be done by creating a dll file and can be called in labview.Can any body expalin how to create a DLL from the c code and be used with this RT controlelr?
    Regards,
    Vishnu

    vishnu123 wrote:
    Hi,
    Earlier in this forum itself in cRIO 900x controllers will run Pharlap and run C/C++ code compiled into .dll files.Can you please tell how to transfer the created DLL to RT controller memory throght FTP?
    Thanks and regards,
    Vishnu
    There is another KB article about this for Pharlap based controllers. And you are right the earlier CompactRIO controllers were Pharlap based. Basically for a deployed application to work, you need to put the DLL through FTP in "/ni-rt/system". If you deploy it directly from the project everything will be loaded into memory through the project environment itself including directly dependable DLLs, (but of course won't survive a power cycle).
    I hope you are aware that while Windows DLLs can work on Pharlap OS they by no means will do so always. The Pharlap OS has not a fully featured Windows API. Also you need to be careful which version of Visual C you are going to use depending on the Pharlap OS version, since the VC runtime DLLs already present on the controller will need to be the same as the ones your Visual C environment likes to link in. Recent Pharlap OS versions use the msvcr71.dll. It's very possible that those runtime libraries can't just simply be copied from a normal Windows installation but might have been recompiled by NI specifically for their controller targets.
    So to avoid problems it's a good idea to make sure your DLL uses the same runtime library DLL or make your DLL to include the static MS runtime.
    Rolf Kalbermatter
    Message Edited by rolfk on 02-05-2008 09:51 AM
    Message Edited by rolfk on 02-05-2008 09:53 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Running a jar file from java code

    Hi!
    Im trying to run a jar file from my code.
    I've tried Classloader, but that doesnt work because it doesnt find the images (also embedded in the 2nd jar file).
    WHat I would like to do is actually RUN the 2nd jar file from the first jar file. There must be a way to do this right?
    any ideas?

    ok, I found some wonderful code (see below) that will try to start the jar. But it doesn't. What it does is produce the following error when my application runs...
    So it's not finding the images in the jar file that I am trying to run? Strange. I checked the URL that sending, but it seems ok....
    I think I will check the url again to make sure......
    any ideas?
    Uncaught error fetching image:
    java.lang.NullPointerException
         at sun.awt.image.URLImageSource.getConnection(Unknown Source)
         at sun.awt.image.URLImageSource.getDecoder(Unknown Source)
         at sun.awt.image.InputStreamImageSource.doFetch(Unknown Source)
         at sun.awt.image.ImageFetcher.fetchloop(Unknown Source)
         at sun.awt.image.ImageFetcher.run(Unknown Source)
    the code....
    /* From http://java.sun.com/docs/books/tutorial/index.html */
    import java.io.IOException;
    import java.lang.reflect.InvocationTargetException;
    import java.lang.reflect.Method;
    import java.lang.reflect.Modifier;
    import java.net.JarURLConnection;
    import java.net.MalformedURLException;
    import java.net.URL;
    import java.net.URLClassLoader;
    import java.util.jar.Attributes;
    * Runs a jar application from any url. Usage is 'java JarRunner url [args..]'
    * where url is the url of the jar file and args is optional arguments to be
    * passed to the application's main method.
    public class JarRunner {
      public static void main(String[] args) {
        URL url = null;
        try {
          url = new URL(args[0]);//"VideoTagger.jar");
        } catch (MalformedURLException e) {
          System.out.println("Invalid URL: ");
        // Create the class loader for the application jar file
        JarClassLoader cl = new JarClassLoader(url);
        // Get the application's main class name
        String name = null;
        try {
          name = cl.getMainClassName();
        } catch (IOException e) {
          System.err.println("I/O error while loading JAR file:");
          e.printStackTrace();
          System.exit(1);
        if (name == null) {
          fatal("Specified jar file does not contain a 'Main-Class'"
              + " manifest attribute");
        // Get arguments for the application
        String[] newArgs = new String[args.length - 1];
        System.arraycopy(args, 1, newArgs, 0, newArgs.length);
        // Invoke application's main class
        try {
          cl.invokeClass(name, newArgs);
        } catch (ClassNotFoundException e) {
          fatal("Class not found: " + name);
        } catch (NoSuchMethodException e) {
          fatal("Class does not define a 'main' method: " + name);
        } catch (InvocationTargetException e) {
          e.getTargetException().printStackTrace();
          System.exit(1);
      private static void fatal(String s) {
        System.err.println(s);
        System.exit(1);
    * A class loader for loading jar files, both local and remote.
    class JarClassLoader extends URLClassLoader {
      private URL url;
       * Creates a new JarClassLoader for the specified url.
       * @param url
       *            the url of the jar file
      public JarClassLoader(URL url) {
        super(new URL[] { url });
        this.url = url;
       * Returns the name of the jar file main class, or null if no "Main-Class"
       * manifest attributes was defined.
      public String getMainClassName() throws IOException {
        URL u = new URL("jar", "", url + "!/");
        JarURLConnection uc = (JarURLConnection) u.openConnection();
        Attributes attr = uc.getMainAttributes();
        return attr != null ? attr.getValue(Attributes.Name.MAIN_CLASS) : null;
       * Invokes the application in this jar file given the name of the main class
       * and an array of arguments. The class must define a static method "main"
       * which takes an array of String arguemtns and is of return type "void".
       * @param name
       *            the name of the main class
       * @param args
       *            the arguments for the application
       * @exception ClassNotFoundException
       *                if the specified class could not be found
       * @exception NoSuchMethodException
       *                if the specified class does not contain a "main" method
       * @exception InvocationTargetException
       *                if the application raised an exception
      public void invokeClass(String name, String[] args)
          throws ClassNotFoundException, NoSuchMethodException,
          InvocationTargetException {
        Class c = loadClass(name);
        Method m = c.getMethod("main", new Class[] { args.getClass() });
        m.setAccessible(true);
        int mods = m.getModifiers();
        if (m.getReturnType() != void.class || !Modifier.isStatic(mods)
            || !Modifier.isPublic(mods)) {
          throw new NoSuchMethodException("main");
        try {
          m.invoke(null, new Object[] { args });
        } catch (IllegalAccessException e) {
          // This should not happen, as we have disabled access checks
    }

  • How to create xml file from Oracle and sending the same xml file to an url

    How to create xml file from Oracle and sending the same xml file to an url

    SQL/XML (XMLElement, XMLForest, XMLAgg, etc) and UTL_HTTP.
    Whether that works for you with the version of Oracle you have, your requirements, and needs is another story. A little detail goes a long way.

  • How many Ways jar files from ear file on a jboss can be downloaded on clien

    Aoa
    How many Ways jar files from ear file on a jboss can be downloaded on client side
    like jnlp etc..
    Regards
    M Fazal Ur Rehman

    First, you need to be able to boot from the Recovery HD:
    Boot Using Command+R keys:
      1. Restart the computer.
      2. Immediately after the chime press and hold down the
          "COMMAND" and the "R" keys together.
      3. Release the keys when the Utilities Menu appears.
    Once at the Utilities Menu select Terminal from the Utilities menu in the screen's menubar. Now, you need to know where these new files are located. You move to any location using the 'cd' command such as cd /Users/user_name/Documents, then press RETURN. Replace user_name with your actual username. Next you need to do a directory listing to see if your files are in that location, Documents. Use ls -al to do a directory listing of the files and folders in Documents. If you find your new files there, then connect an external drive or flash drive. You will need to know the name you have assigned to this drive. It needs to be already formatted. Copy your files using cp /Documents/filename /Volumes/volname/filename. Replace volname and filename with those that apply. Press RETURN.
    Or take it to your local Apple Store and see if they can do the chore for you.

  • How to run .jar on linux & how to create .jar file using java?

    hi, may i know how to run .jar on linux & how to create .jar file using java? Can u provide the steps on doing it.
    thanks in advance.

    Look at the manual page for jar:
    # man jar
    Also you can run them by doing:
    # java -jar Prog.jar

  • How to create .JAR file in JSE 8?

    I don't know how to create a .JAR file from my project. I found a .JAR file in .../dist under my project folder, but I could not run it.

    This Swing app has 2 class files, requires Swing Library to be imported (of course), and requires no other files. It seems like the program does not import Swing Lib. so that it can display the JFrame inside.
    1. I have JRE installed separately so I can run Jar files directly by double-clicking. I also tried to run within command prompt, and had the same result. No error or exception warning found.
    2. As I said, the program requires no other files.
    3. I repeat that it works fine within JSE as well as JBuilder. the Jar created by JBuilder (same code) works fine, too.
    4. This Jar file is the only one Jar that I found in my project folder, and has the same name with the project. (But anyway, there's no folder contains 2 files with the same name, so this verification is not necessary).

  • OAS form services "Deploy Icons" how 2 create Jar file?

    hi all!
    i have win2000 and 10g oas form services
    how 2 execute this command for deploying icon(gif)?
    =====
    My Application Directory is
    D:\myapp\icon
    the commad to execute in this directory is
    <oracle_home>jdk/bin jar -cvf myappIcon.jar *.gif
    HOW TO EXECUTE THIS COMMAND FROM D:\myapp\icon directory?
    i try this
    D:\myapp\icon cd d:\oracle_home\jdk\bin jar -cvf myappicon.jar *.gif
    it gives error
    file name ,directory name, volume lable syntax incorrect
    Please give me commad example for this
    Thanks

    Hi Dear Frank and 422828!
    In responce to ur reply what i have done is ..
    1- I have add the directory "D:\frs\jdk\bin;" to the PATH variable.. (!it works Dear 422828 thanks 4 this)
    2-i have created the .jar file using following command
    D:\myapp\icon> jar -cvf myappicon.jar *.gif
    This myappicon.jar file was created in D:\myapp\icon directory
    then i 'CUT' this myappicon.jar file from here and copy to the
    D:\frs\forms90\java directory
    3-then i stop all component in oas10g(form and services) AS control page
    4- then i open formsweb.cfg and edit this as following..
    [myApp]
    …
    archive_jini=f90all_jini.jar,myAppIcons.jar
    imagebase=codebase
    and save it.
    5-then i start all component in oas10g(form and services) AS control page
    6-then i edit my form's button's icon name property
    some button to "save" and some button to "save.gif"
    7- then i start the form by giving the following URL in the Browser
    http;\\mymachine.com:7778/forms90/f90servlet?config=myapp
    then the browser show this message
    "java.lang.classNotFoundExcption:oracle.forms.engine.Main"
    Note! i have tried "Entering The Fast Lane" in ur white paper
    Now what i should do or what are the error or what i missed please mention or guide me
    Now should i try the "BEST PRACTICES" on ur white paper?
    Please guide me
    thanks
    Rana Adnan

  • Help! How to create Jar file for a packaged class?

    Hi!
    I am new in jar complexities. I made a swing frame that just prompts a JOptionPane when executed. I accomplished the same using jar without packaging my class SwingTest.
    But when i package it, it doesn't run. Can any one tell me how to make jar file of packaged classes and include images in the jar files too!
    Really Thanx!

    Call the Jar from the commandline to see the exceptions thrown.
    java -jar <jarFileName> <className>

  • How to include .jar files in coldfusion code 

    To Integrate our cfm code with paypal jar files we do the
    following steps with our local coldfusion server ,and to run and
    integrate the paypal Java SDK jar files, I think we need to do the
    same process on the server, can you suggest any thing to do the
    following setting for my domain on the server, without setting the
    class path in coldfusion administrator.
    The ColdFusion application server must be configured to know
    the location of the PayPal JAR
    files, and your ColdFusion Markup (CFM) pages must be
    configured with the absolute path to
    the PayPal API certificate for the PayPal API user on whose
    behalf the calls are made.
    1. Install the PayPal Java SDK “Installing the
    SDK”.
    2. Copy a subset of the Java SDK JAR files to a location
    accessible by the ColdFusion
    application server. The JAR files are in SDK_root\lib and
    their exact names are as
    follows:
    – bcmail-jdk14-128.jar
    – bcprov-jdk14-128.jar
    – paypal_base.jar
    – paypal_stubs.jar
    sax2.jar
    – xerces.jar
    – xpp3-1.1.3.4d_b4_min.jar
    – xstream.jar-1.1.3.jar
    3. With the ColdFusion Application Server Administrator, add
    the absolute path of the
    location you determined in Step 2 to the Java and JVM
    CLASSPATH environment variable.
    4. Restart the ColdFusion Application Server.
    Suggest me how to include .jar files without setting
    classpath.

    > Suggest me how to include .jar files without setting
    classpath.
    Copy them to {CF_HOME}\lib, where {CF_HOME} is, for example,
    C:\CFusionMX7. Restart Coldfusion.

  • How to load jar files from remote location

    Hi all,
    I am trying to load jar files from remote server, from a servlet which is running on OC4j.
    For doing this,First I am getting ClassLoader by using ClassLoader.getSystemClassLoader() and then type casting it to URLClassLoader.
    But by doing it I am getting ClassCastException,because oc4j returns oracle.classloader.PolicyClassLoader instead of java.net.ClassLoader.
    Appreciate if anyone can tell me how to load remote jar files using oracle.classloader.PolicyClassLoader .
    Thanks
    Harish

    Hi,
    I suppose you know about this, but just in case.
    I have used jnpl to load jar files from remote location.
    Rowan

  • How to create UTL file from on Unix server

    Hi,
    I have created a stored procedure in Oracle (8.0.6) which will create a flat file using UTL_File. The oracle server is running on unix system.
    When I am executing the PL/SQL procedure from Unix's Sql Plus, it is creating the file properly. When I try to execute the same from a windows client using SQL Plus / PLSQL Developer, It is not creating the file.
    Any input is worh.
    also, pls find below the code I am using.
    P_Dir = ' /apps/ullcis/dev/data'
    P_File = 'test.log'
    dbms_output.put_line('In Create Log File ');
    l_file_handle := UTL_FILE.FOPEN(P_Dir,P_File, 'w');
    dbms_output.put_line('Opened in Write');
    UTL_FILE.PUT_LINE (l_file_handle,'sample text');
    UTL_File.fflush(l_file_handle);
    UTL_FILE.FCLOSE (l_file_handle);
    Regards
    Sam

    I'm writing to unix file path not onto the windows client.And i have permission in that unix direcotry to create a file.The above code does well if invoked from sql prompt of unix but it does not create file, if i invoke from sqlplus in windows client. Any help ...?
    Thanks

  • Running .jar files from Java code

    Hi.
    I am designing a sort of platform to run some games which are saved in .jar files. Basically this platform is a menu from which the user can select the game which he/she wants to run. It also has the feature of adding new games.
    Is is possible to run the .jar file from within java code?
    Thanks for any help!
    Krt_malta

    Just list the jar in the classpath list and call the class in the jar.

  • How to create xml file from original

    I have this complicated xml and I want to search through it and make a new xml with only element I find that match. what is the best way to do this? the file
    is about 6mb and I want to read the whole file easily..should i load to database table and create a file from table? I have found issues reading the file..
    - <ArrayOfJobClass xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    - <JobClass>
    - <Triggers>
    - <TriggerClass>
    <ExpireActionType>Delete</ExpireActionType>
    <ExpireType>DateTime</ExpireType>
    <TriggerType>TimeType</TriggerType>
    - <TTime>
    <TimeTriggerType>Custom</TimeTriggerType>
    <IntervalType>Daily</IntervalType>
    <SpecificType>Days</SpecificType>
    <FirstLastType>First</FirstLastType>
    <IntervalValue>1</IntervalValue>
    <FirstLastWeekDay>Monday</FirstLastWeekDay>
    <InitDate>2009-05-04T14:17:05.40625-07:00</InitDate>
    - <IntervalDays>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>
    <boolean>false</boolean>

    You can load it in the database in an XMLType table (Object-Relational or Binary XML storage), use XQuery on the XML content and then write back the result to a file.
    Or, you might just use an external processor (XSLT or XQuery).
    If you want to stay in the Oracle world, you can use :
    - For XSLT : $ORACLE_HOME/bin/oraxsl (it's a wrapper for the java XSLT engine)
    - For XQuery : the java XQuery API
    Personally, I sometimes use the Saxon XSLT and XQuery processor, quite efficient.
    Here's a simplistic example with oraxsl utility :
    emp.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <emps>
      <emp id="7369">
        <name>SMITH</name>
        <job>CLERK</job>
        <salary>800</salary>
      </emp>
      <emp id="7499">
        <name>ALLEN</name>
        <job>SALESMAN</job>
        <salary>1600</salary>
      </emp>
      <emp id="7521">
        <name>WARD</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp>
      <emp id="7566">
        <name>JONES</name>
        <job>MANAGER</job>
        <salary>2975</salary>
      </emp>
      <emp id="7654">
        <name>MARTIN</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp>
    </emps>
    emp.xsl
    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method="xml"/>
    <xsl:template match="text()"/>
    <xsl:template match="emps/emp[job='SALESMAN']">
      <xsl:copy-of select="."/>
    </xsl:template>
    </xsl:stylesheet>Applying the transformation to search and extract all "salesmen" :
    D:\ORACLE\test>%ORACLE_HOME%\bin\oraxsl emp.xml emp.xsl result.xml
    D:\ORACLE\test>type result.xml
    <?xml version = '1.0' encoding = 'UTF-8'?>
    <emp id="7499">
        <name>ALLEN</name>
        <job>SALESMAN</job>
        <salary>1600</salary>
      </emp><emp id="7521">
        <name>WARD</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp><emp id="7654">
        <name>MARTIN</name>
        <job>SALESMAN</job>
        <salary>1250</salary>
      </emp>

  • HOW TO CREATE PDF FILES FROM AUTOCAD 12

    I'M USING ACROBAT X TO CREATE PDF FILES FROM AUTOCAD 12 DRAWINGS.  THE PROGRAM RANDOMLY LEAVES OUT TEXT AND IMAGES.  IT ALSO STRUGGLES WITH TIFF, JPEG AND PDF IMAGE FILES EMBEDDED WITHIN THE AUTOCAD DRAWING.  THIS HAS BEEN AN ONGOING PROBLEM WITH ACROBAT.  I WAS HOPING THE UPGRADE TO  X WOULD ELIMINATE THE PROBLEM BUT IT HAS NOT.

    Hi Joao,
                    Verify these links hope it may helps...
    http://www.devx.com/xml/Article/16430/1954
    http://technopaper.blogspot.com/2008/06/using-xsl-fo-to-create-pdf-files.html
    http://www.ibm.com/developerworks/xml/library/x-xslfo/
    http://www.antennahouse.com/XSLsample/XSLsample.htm
    Regards,
    Anil.

Maybe you are looking for

  • Error While Archiving

    Hi All I am getting an error of  "All available file names are already being used " while archiving the ODS. On other side when i search for the same available files i did not get that. So i want to know where i can look for the available files? Also

  • In va01 condition types are appearing twice

    Hi In the pricing conditions screen of sales order I find that all the condition types are appearing twice and also calculted taxes twice.please give me solution

  • IWeb won't publish pictures in sRGB

    Hi all, Got iWeb 09 and running it on latest OS on MacBook Pro. Here is the problem - no mater what options i choose - it publishes pictures in some other profile other than sRGB. The problem is that when viewed in anything other than Safari - pictur

  • Portal Upgrade to SP18 CVersAccessException

    Hi all, I am trying to upgrade our portal from SP14 to SP18 and getting following error message: Caught CVersProxyAccessException while saving repository: CVersAccessException: Can not load mandatory table BC_COMPVERS, desc == null Some components we

  • E4200v2 Smart Wi-Fi Firmware release notes?

    Does anyone have a link to the release notes of the latest firmware Ver.2.1.39.144146? The release notes link at http://homesupport.cisco.com/en-us/support/routers/E4200  shows the License Agreetment instead  Solved! Go to Solution.