Output to textfiles in a jar file.

To get what was in the text file i set it up liek this.
BufferedReader d = new BufferedReader(new InputStreamReader(getClass().getResourceAsStream("Settings.txt")));
then
String str= d.readLine(); and so on.
How would i output to that file in my jar?
Thanks

sorry i should be more specific.
That file already exists in my jar.
i got it, did somethign with the values in it now i want to get an outputstream to write something back out.

Similar Messages

  • Adding JAR file to project

    Hi All
    How can i add jar to my project environment.
    Actually what i did was.
    Created one folder called "JavaWork" like d:\JavaWork
    and put the jar file into this folder and wrote a test class which is importing some classes from the jar file.
    how to use jar ? Please someone help me.
    Thanks in advance
    Shan

    `man jar`
    jar(1) jar(1)
    NAME
    jar - Java archive tool
    SYNOPSIS
    jar [ -C ] [ c ] [ f ] [ i ] [ M ] [ m ] [ O ] [ t ] [ u ]
    [ v ]
    [ x file ] [ manifest-file ] destination input-file
    [ input-files ]
    DESCRIPTION
    The jar tool is a Java application that combines multiple
    files into a single JAR archive file. It is also a gen-
    eral-purpose archiving and compression tool, based on ZIP
    and the ZLIB compression format. However, jar was
    designed mainly to facilitate the packaging of Java
    applets or applications into a single archive. When the
    components of an applet or application (.class files,
    images and sounds) are combined into a single archive,
    they can be downloaded by a Java agent (like a browser) in
    a single HTTP transaction, rather than require a new con-
    nection for each piece. This dramatically improves down-
    load time. The jar tool also compresses files, which fur-
    ther improves download time. In addition, it allows indi-
    vidual entries in a file to be signed by the applet author
    so that their origins can be authenticated. The syntax
    for the jar tool is almost identical to the syntax for the
    tar(1) command. A jar archive can be used as a class path
    entry, whether or not it is compressed.
    The three types of input files for the jar tool are:
    o Manifest file (optional)
    o Destination jar file
    o Files to be archived
    Typical usage is:
    example% jar cf myjarfile *.class
    In this example, all the class files in the current direc-
    tory are placed in the file named myjarfile. A manifest
    file is automatically generated by the jar tool and is
    always the first entry in the jar file. By default, it is
    named META-INF/MANIFEST.MF. The manifest file is the
    place where any meta-information about the archive is
    stored. Refer to the Manifest Format in the SEE ALSO sec-
    tion for details about how meta-information is stored in
    the manifest file.
    To use a pre-existing manifest file to create a new jar
    archive, specify the old manifest file with the m option:
    example% jar cmf myManifestFile myJarFile *.class
    When you specify cfm instead of cmf (that is, you invert
    the order of the m and f options), you need to specify the
    name of the jar archive first, followed by the name of the
    manifest file:
    example% jar cfm myJarFile myManifestFile *.class
    The manifest uses RFC822 ASCII format, so it is easy to
    view and process manifest-file contents.
    OPTIONS
    The following options are supported:
    -C Changes directories during execution of the jar com-
    mand. For example:
    example% jar uf foo.jar -C classes *
    c Creates a new or empty archive on the standard out-
    put.
    f The second argument specifies a jar file to process.
    In the case of creation, this refers to the name of
    the jar file to be created (instead of on stdout).
    For table or xtract, the second argument identifies
    the jar file to be listed or extracted.
    i Generates index information for the specified jar
    file and its dependent jar files. For example,
    example% jar i foo.jar
    would generate an INDEX.LIST file in foo.jar which con-
    tains location information for each package in foo.jar and
    all the jar files specified in foo.jar's Class-Path
    attribute.
    M Does not create a manifest file for the entries.
    m Includes manifest information from specified pre-
    existing manifest file. Example use:
    example% jar cmf myManifestFile myJarFile *.class
    You can add special-purpose name-value attribute
    headers to the manifest file that are not contained
    in the default manifest. Examples of such headers
    are those for vendor information, version informa-
    tion, package sealing, and headers to make JAR-bun-
    dled applications executable. See the JAR Files
    trail in the Java Tutorial and the JRE Notes for
    Developers web page for examples of using the m
    option.
    O Stores only, without using ZIP compression.
    t Lists the table of contents from standard output.
    u Updates an existing JAR file by adding files or
    changing the manifest. For example:
    example% jar uf foo.jar foo.class
    adds the file foo.class to the existing JAR file
    foo.jar, and
    example% jar umf foo.jar
    updates foo.jar's manifest with the information in
    manifest.
    v Generates verbose output on stderr.
    x file
    Extracts all files, or just the named files, from
    standard input. If file is omitted, then all files
    are extracted; otherwise, only the specified file or
    files are extracted.
    If any of the files is a directory, then that direc-
    tory is processed recursively.
    EXAMPLES
    To add all of the files in a particular directory to an
    archive:
    example% ls
    0.au 3.au 6.au 9.au at_work.gif
    1.au 4.au 7.au Animator.class monkey.jpg
    e.au 5.au 8.au Wave.class spacemusic.au
    example% jar cvf bundle.jar *
    adding: 0.au
    adding: 1.au
    adding: 2.au
    adding: 3.au
    adding: 4.au
    adding: 5.au
    adding: 6.au
    adding: 7.au
    adding: 8.au
    adding: 9.au
    adding: Animator.class
    adding: Wave.class
    adding: at_work.gif
    adding: monkey.jpg
    adding: spacemusic.au
    example%
    If you already have subdirectories for images, audio
    files, and classes that already exist in an HTML direc-
    tory, use jar to archive each directory to a single jar
    file:
    example% ls
    audio classes images
    example% jar cvf bundle.jar audio classes images
    adding: audio/1.au
    adding: audio/2.au
    adding: audio/3.au
    adding: audio/spacemusic.au
    adding: classes/Animator.class
    adding: classes/Wave.class
    adding: images/monkey.jpg
    adding: images/at_work.gif
    example% ls -l
    total 142
    drwxr-xr-x 2 brown green 512 Aug 1 22:33 audio
    -rw-r--r-- 1 brown green 68677 Aug 1 22:36 bundle.jar
    drwxr-xr-x 2 brown green 512 Aug 1 22:26 classes
    drwxr-xr-x 2 brown green 512 Aug 1 22:25 images
    example%
    To see the entry names in the jar file using the jar tool
    and the t option:
    example% ls
    audio bundle.jar classes images
    example% jar tf bundle.jar
    META-INF/MANIFEST.MF
    audio/1.au
    audio/2.au
    audio/3.au
    audio/spacemusic.au
    classes/Animator.class
    classes/Wave.class
    images/monkey.jpg
    images/at_work.gif
    example%
    To display more information about the files in the
    archive, such as their size and last modified date, use
    the v option:
    example% jar tvf bundle.jar
    145 Thu Aug 01 22:27:00 PDT 1996 META-INF/MANIFEST.MF
    946 Thu Aug 01 22:24:22 PDT 1996 audio/1.au
    1039 Thu Aug 01 22:24:22 PDT 1996 audio/2.au
    993 Thu Aug 01 22:24:22 PDT 1996 audio/3.au
    48072 Thu Aug 01 22:24:23 PDT 1996 audio/spacemusic.au
    16711 Thu Aug 01 22:25:50 PDT 1996 classes/Animator.class
    3368 Thu Aug 01 22:26:02 PDT 1996 classes/Wave.class
    12809 Thu Aug 01 22:24:48 PDT 1996 images/monkey.jpg
    527 Thu Aug 01 22:25:20 PDT 1996 images/at_work.gif
    example%
    If you bundled a stock trade application (applet) into the
    following jar files,
    main.jar buy.jar sell.jar other.jar
    and you specified the Class-Path attribute in main.jar's
    manifest as
    Class-Path: buy.jar sell.jar other.jar
    then you can use the i option to speed up your applica-
    tion's class loading time:
    example$ jar i main.jar
    An INDEX.LIST file is inserted in the META-INF directory
    which will enable the application class loader to download
    the right jar files when it is searching for classes or
    resources.
    SEE ALSO
    keytool(1)
    JAR Files @
    http://java.sun.com/docs/books/tutorial/jar/
    JRE Notes @
    http://java.sun.com/j2se/1.3/runtime.html#exam-
    ple
    JAR Guide @
    http://java.sun.com/j2se/1.3/docs/guide/jar/index.html
    For information on related topics, use the search link @
    http://java.sun.com/
    13 June 2000 jar(1)

  • JAR file tip for winXP users

    AAAAGH!
    I've just discovered why my JAR file is SO big. Stupid winXP generates a hidden file called Thumbs.db in directories containing images if you browse them in the file explorer. If you add this directory to your JAR file it will include this file. This added 3MB to my JAR - removing it the JAR is under 2MB!
    Tip - check the output when you create a jar file!

    Yeah, this is truly irritating. Thumbs.db is a thumbnail cache and it's the price you pay to have the Fisher Price GUI Windoze XP is so well known for. You may notice if you chage these images all the time that the cache images don't match the actual images.
    The best solution? Stop the damn thing altogether. To stop it do this:
    Go to run and start regedit.exe then go to the HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced
    Double-click DisableThumbnailCache value and change the value to 1 and press ok and close the registry editor then restart ur machine.

  • Decompiling jar file and then run

    Dear Members,
    I have a jar file and I have decompiled that jar file and converted into class file,
    now I want to run/edit using source code ,I am unable to run source code with out put whatever coming in jar file running,
    I am trying with class in which
    public static void main(String[] args)
    function defined,
    I am using Jcreater1.5 and from command prompt also running but unable to run and edit the programm,
    how to run these class file in complete project that output will come as running jar file
    regards
    SACHIN

    It sounds like you have unpacked the jar.
    To edit the source you need to decompile the classes to .java files.
    [http://www.google.co.uk/search?q=java+decompiler]

  • Code ran fine in Eclipse, no output as a Jar file..help!

    I have been working on a piece of code that reads an excel spreadsheet, and writes xml files based on that. (I'm to cheap to buy the numerous software out there)
    The code ran beautifully in Eclipse, and all the right dialog windows and console outputs were present, as well as the final product, about 250 XML files.
    I exported the src to a sealed jar file and ran it.
    I get the first few dialogs that ask info of me, but as soon as it starts the process I get nothing!...
    no exceptions, no errors, no xml...does anyone know what i did wrong?
    Thanks so much for the help.

    we can't help you if we don't know the real probelm you've got.
    use an error logger like log4j http://logging.apache.org/log4j/docs/index.html and report the exception messages.

  • Adogjf Unable to generate jar files under JAVA_TOP error while patching

    Hi,
    I'm upgrading my version of Java from 1.3.1_19 to 1.5.0_17. I downloaded the jdk-1_5_0_17-linux-i586.bin file and unpackaged it to /u0/<SID>/<SID>db/10.2.0. It unpackaged it to a new directory jdk1.5.0_17 (/u0/<SID>/<SID>db/10.2.0/jdk1.5.0_17), whereas the old version is in a directory jdk (/u0/<SID>/<SID>db/10.2.0/jdk).
    Having done that I had to run an interoperability patch (4372996). Upon running this patch I received an error at the end:
    adogjf() Unable to generate jar files under JAVA_TOP
    There were no other errors.
    I think the problem has to do with where my new java version is located but I'm not sure. I'm thinking that it's still looking under the old JAVA_TOP (/u0/<SID>/<SID>db/10.2.0/jdk) when I want it to look under the new JAVA_TOP (/u0/<SID>/<SID>db/10.2.0/jdk1.5.0_17). So, should I move the contents from the new directory (jdk1.5.0_17) to the old directory (jdk) or is there a way to 'point' it to the new JAVA_TOP.
    Please let me know if I'm totally off base and there's another solution. We're currently on EBS 11.5.10.2, DB 10.2.0.4 and RHEL 4 Update 5.
    Thanks,
    Lia.

    Here you go. Hope this helps you to help me :-). Thanks.
    +
    ** Generating the product JAR files...
    STRT_TASK: [Generate JAR files] [] [Fri Mar 27 2009 09:20:32]
    STRT_TASK: [Generate JAR files under JAVA_TOP] [] [Fri Mar 27 2009 09:20:32]
    Signing product JAR files in JAVA_TOP -
    /u0/mary/marycomn/java
    using entity Customer and certificate 1.
    Calling /u0/mary/marycomn/util/jre/1.1.8/bin/jre ...
    Successfully created javaVersionFile.
    Generating product JAR files in JAVA_TOP -
    /u0/mary/marycomn/java with command:
    adjava -mx512m -nojit oracle.apps.ad.jri.adjmx @/u0/mary/maryappl/admin/mary/out/genjars.cmd
    Reading product information from file...
    Reading language and territory information from file...
    Reading language information from applUS.txt ...
    Temporarily resetting CLASSPATH to:
    "/u0/mary/maryappl/ad/11.5.0/java/adjri.zip:/u0/mary/marycomn/util/jre/1.1.8/lib/rt.jar:/u0/mary/marycomn/util/jre/1.1.8/lib/i18n.jar:/u0/mary/marycomn/util/jre/1.1.8/lib/tools.jar:/u0/mary/marycomn/java/appsborg.zip:/u0/mary/marycomn/java/apps.zip:/u0/mary/maryora/8.0.6/forms60/java:/u0/mary/marycomn/java"
    Calling /u0/mary/marycomn/util/jre/1.1.8/bin/jre ...
    The JDK version is 1.1.8
    Validating the files/directories specified for -areas option
    Validating the files/directories specified for -outputSpec option
    Validating the directory specified for -lstDir option
    About to Analyze the input areas : Fri Mar 27 2009 09:20:36
    WARNING: Will not load stale resource unit META-INF/services/javax.xml.parsers
    WARNING: Will not load stale resource unit META-INF/services/javax.xml.transform
    Done Analyzing the input areas : Fri Mar 27 2009 09:20:43
    About to Analyze/Generate jar files : Fri Mar 27 2009 09:20:43
    About to Analyze fndnetcharts.jar : Fri Mar 27 2009 09:20:43
    Up-to-date : fndnetcharts.jar
    Done Analyzing fndnetcharts.jar : Fri Mar 27 2009 09:20:44
    About to Analyze fndtdg.jar : Fri Mar 27 2009 09:20:44
    Up-to-date : fndtdg.jar
    Done Analyzing fndtdg.jar : Fri Mar 27 2009 09:20:44
    About to Analyze fndjgl.jar : Fri Mar 27 2009 09:20:44
    Up-to-date : fndjgl.jar
    Done Analyzing fndjgl.jar : Fri Mar 27 2009 09:20:45
    About to Analyze fndjle.jar : Fri Mar 27 2009 09:20:45
    Up-to-date : fndjle.jar
    Done Analyzing fndjle.jar : Fri Mar 27 2009 09:20:47
    About to Analyze fndlrucache.jar : Fri Mar 27 2009 09:20:47
    Up-to-date : fndlrucache.jar
    Done Analyzing fndlrucache.jar : Fri Mar 27 2009 09:20:47
    About to Analyze fndgantt.jar : Fri Mar 27 2009 09:20:47
    Up-to-date : fndgantt.jar
    Done Analyzing fndgantt.jar : Fri Mar 27 2009 09:20:47
    About to Analyze fndpromise.jar : Fri Mar 27 2009 09:20:47
    Up-to-date : fndpromise.jar
    Done Analyzing fndpromise.jar : Fri Mar 27 2009 09:20:48
    About to Analyze fndforms.jar : Fri Mar 27 2009 09:20:48
    About to Generate fndforms.jar : Fri Mar 27 2009 09:20:49
    Done Generating fndforms.jar : Fri Mar 27 2009 09:20:50
    About to Sign fndforms.jar : Fri Mar 27 2009 09:20:50
    ERROR: Javakey subcommand exited with status 1
    Javakey standard output:
    Adding entry: META-INF/MANIFEST.MF
    Copyright (c) 2002 Oracle Corporation
    Redwood Shores, California, USA
    AD Java Key Generation
    Version 11.5.0
    NOTE: You may not use this utility for custom development
    unless you have written permission from Oracle Corporation.
    Javakey error output:
    Reading product information from file...
    Reading language and territory information from file...
    Reading language information from applUS.txt ...
    Successfully created javaVersionFile.
    Customer not found in database.
    java key error:
    adjava -ms128m -mx256m sun.security.provider.Main -gs /u0/mary/marycomn/java/oracle/apps/fnd/jar/fndforms.jar.tmp /u0/mary/marycomn/java/oracle/apps/fnd/jar/fndforms.jar.uns
    The above Java program failed with error code 1.
    Done Analyzing/Generating jar files : Fri Mar 27 2009 09:20:51
    AD Run Java Command is complete.
    Copyright (c) 2002 Oracle Corporation
    Redwood Shores, California, USA
    AD Java
    Version 11.5.0
    NOTE: You may not use this utility for custom development
    unless you have written permission from Oracle Corporation.
    Failed to generate product JAR files in JAVA_TOP -
    /u0/mary/marycomn/java.
    adogjf() Unable to generate jar files under JAVA_TOP
    AutoPatch error:
    Failed to generate the product JAR files
    You should check the file
    /u0/mary/maryappl/admin/mary/log/4372996.log
    for errors.
    +

  • My JAR file is not working properly!!!

    Hi everyone,
    I made an application that has a GUI (window). I converted it into a JAR file so I can send it to a friend by email. Then she can run it to generate the output. First, the user has to select a destination to save the .txt file (using JFileChooser). Then enters the inputs (using JTextFields). Clicks "Run" button (Results will be calculated and copied to the file). A Message will appear indicating that the results are copied. The problem is that when I run the application in the IDE (Eclipse) it works fine. But when I convert it into JAR, The moment I click the "Run" button, suddenly the window closes. Please HELP???
    Thank you

    DrClap wrote:
    Eng.Sh_2004 wrote:
    Sorry guys, but i would like to make things clearer, As I mentioned earlier, What i'm doing is the following: 1) Using the Jfilechooser, save the results into a filename.txt file _[main class in the manifest file (class for the GUI) ]._ 2) Click "run" to write the data to the created file in step 1 [_another class is used to write to file_]. I have a feeling that the problem is related to the manifest main class. What do you think guys?I think your description of the problem is very bad. And I think your idea of making wild guesses is a bad way of diagnosing problems.
    First of all. A JFileChooser does not save anything. It just allows the user to select a file to be saved to. So if you thought that the first step was writing anything or creating any file, you're probably wrong. But examining the code would help you understand.
    Second, if you're having problems because one class chooses the file name and a second class writes data to it, then you're probably running into the basic beginner problem we see around here all the time of how to communicate data between objects. Again, examining the code might help.
    Third, you need to understand what is writing that error message. Examining the code would help there too.
    So: stop guessing. Look at the code.I'm still New To Java that's why i find difficulty in problems diagnosis. Regarding the JAR problem, as you mentioned, I used JFileChooser to select a file and (copying data) is the other part. So I will look at the code again.
    Edited by: Eng.Sh_2004 on Aug 26, 2010 1:10 PM

  • OC4J: Class not found for class in jar file placed in \j2ee\home\applib\

    I have an ADF application which uses external libraries (jars), which works fine when running the application from within JDeveloper (TP4).
    However if I deploy the application to the embedded OC4J server it won't find any classes imported in those external libraries at runtime (deploy does work). E.g. one library class imports oracle.jbo.server.DBTransaction. If a method of this class is called I get the following exception:
    Unexpected exception caught: java.lang.NoClassDefFoundError, msg=oracle/classloader/util/AnnotatedNoClassDefFoundError
    oracle/classloader/util/AnnotatedNoClassDefFoundErrorThe same exception, when using a german locale, explicitely states that it cannot find oracle.jbo.server.DBTransaction.
    The jar files are placed in the \j2ee\home\applib\ directory and a <library> element to this path is present in application.xml.
    Any further hints what could be wrong?

    Hi Edwin,
    tried your suggestions but without success.
    when I add this library to server.xml then following error occures when starting OC4J
    17.09.2008 17:10:33 oracle.oc4j.util.SystemLog log
    SCHWERWIEGEND: Server start failed processing configuration
    java.lang.InstantiationException: Illegal tag, 'library': The library tag has moved from config/server.xml to config/application.xml, please update your configuration manually or reinstall.
            at com.evermind.server.XMLApplicationServerConfig.parseDeploymentMainNode(XMLApplicationServerConfig.java:1227)
            at com.evermind.xml.XMLConfig.parseRootNode(XMLConfig.java:342)
            at com.evermind.xml.XMLConfig.init(XMLConfig.java:222)
            at com.evermind.xml.XMLConfig.init(XMLConfig.java:154)
            at com.evermind.server.XMLApplicationServerConfig.<init>(XMLApplicationServerConfig.java:237)
            at com.evermind.server.ApplicationServer.createConfig(ApplicationServer.java:661)
            at oracle.oc4j.server.ServerFactory$Worker.prepareConfig(ApplicationServerFactory.java:225)
            at oracle.oc4j.server.ServerFactory$Worker.start(ApplicationServerFactory.java:244)
            at oracle.oc4j.server.ServerFactory$Worker.run(ApplicationServerFactory.java:259)
            at java.lang.Thread.run(Thread.java:619)
    17.09.2008 17:10:33 oracle.oc4j.util.SystemLog logNoStack
    SCHWERWIEGEND: Server exiting: ApplicationServer entered state EXITING--> I added this to application.xml
    Than I enabled more logging of classloader "-Duser.country=US -Dclass.load.log.level=finest"
    Here a snippet of the output at starttime of OC4J:
    ================================
    08/09/18 10:17:07 Initial class loaders created. Uptime: 3156ms.
    08/09/18 10:17:07 Loading main class com.evermind.server.OC4JServer...
    08/09/18 10:17:07 com.evermind.server.OC4JServerMain class loaded. Uptime: 3344ms.
    08/09/18 10:17:07 Transferring to com.evermind.server.OC4JServer.main()...
    08/09/18 10:17:15 Ignoring non-existent code source: D:\oracle\jdevstudio1111_preview4_standalone\j2ee\home\config\..\..\..\BC4J\lib\jmxdc.jar(from <code-source> (ignore manifest Class-Path) in /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/config/server.xml)
    08/09/18 10:17:15 Ignoring <code-source> (ignore manifest Class-Path) in /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/config/server.xml entry: code-source /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/lib/api-ext/adflogginghandler.jar (from system property api.ext.dirs) is already visible in the search path of adf.oracle.domain:11.1.4949.
    08/09/18 10:17:15 Ignoring non-existent code source: D:\oracle\jdevstudio1111_preview4_standalone\j2ee\home\config\..\..\..\BC4J\lib\jmxdc.jar(from <code-source> (ignore manifest Class-Path) in /D:/oracle/jdevstudio1111_preview4_standalone/j2ee/home/config/server.xml)
    08/09/18 10:17:15 Import was not resolved for adf.oracle.domain:11.1.4949: shared library "oracle.fabric.runtime" could not be found.
    08/09/18 10:17:15 Import was not resolved for adf.generic.domain:11.1.4949: shared library "oracle.fabric.runtime" could not be found.Seems that oracle.fabric.runtime couldn't be found but the jar's are located in D:\oracle\jdevstudio1111_preview4_standalone\lib\java\shared\oracle.fabric.runtime\11.1.1.0.0
    It's the same as with my jdeveloper installation where I don't have this problems.
    regards
    Peter

  • Import JAR files (integrating JasperReports)

    Dear all,
    I'm using JDeveloper 11.1.1.3.0 on Windows 7 32bit.
    I search this forum and I google a lot, but I couldn't find any workable solution.
    I downloaded the newest version of JasperReport and iReport from the official website. I've done some tutorials from this site and everything seems to work fine.
    Now I want to integrate JDev with JasperReports. I create new Fusion Web Application ADF, I get the properties of Model project, Libraries and Classpath tab, add Library and click New... I set the Library name as JasperReports, location as Project, check Deploy ad Default. I add to Class path every JAR files in E:\JasperReports\jasperreports-3.7.6\lib and to Source path the whole directory E:\JasperReports\jasperreports-3.7.6\src. I get sure that the Export is checked and I save all the changes.
    I create a new Java Class JasperTest and I use this sample code:
    import net.sf.jasperreports.engine.*;
    import net.sf.jasperreports.engine.export.*;
    import java.util.*;
    public class JasperTest {
        public static void main(String[] args) {
            String fileName = "test.jasper";
            String outFileName = "test.pdf";
            HashMap hm = new HashMap();
            try {
                // Fill the report using an empty data source
                JasperPrint print = JasperFillManager.fillReport(fileName, hm, new JREmptyDataSource());
                // Create a PDF exporter
                JRExporter exporter = new JRPdfExporter();
                // Configure the exporter (set output file name and print object)
                exporter.setParameter(JRExporterParameter.OUTPUT_FILE_NAME, outFileName);
                exporter.setParameter(JRExporterParameter.JASPER_PRINT, print);
                // Export the PDF file
                exporter.exportReport();
            } catch (JRException e) {
                e.printStackTrace();
                System.exit(1);
            } catch (Exception e) {
                e.printStackTrace();
                System.exit(1);
    }I cant compile this, it gives me Error(1,1): package net.sf.jasperreports.engine does not exist etc..
    I cant import any class from JasperReports. Did I something wrong with importing the JAR files to my project ? Maybe I should set some system environment variable ? What else I can do ?
    Any help will be appraciated.
    Regards,
    Wojtek.

    Hi,
    I am also facing the same problem, I have few Jasper Reports which are closely integrated with my APEX applications, but for this i am using another application ( Jasper reports) which deployed in tomcat. This application hardly have 20 lines of java code, so i thought of embedding same in PL/SQL itself, But i am facing problem while importing JAR files i.e.
    1. Where to put these JAR files so that i can import them in my PL/SQL.
    2. I also tried using JAVALOAD function, but that also not worked for me.
    Please give me some solution how to go about it??

  • How to create package and import from jar file?

    Hi all,
    I am writing a software and I am not sure how to create a package for the classes.
    Say I have two classes in the same directory as follows:
    testA.java
    ==========
    package AB;
    public class testA
    public static void main(String[] args){
         testB myB = new testB();
         System.out.println("A test");
    testB.java
    ===========
    package AB;
    public class testB
    public testB(){
         System.out.println("B constructor");
    both file compile without the package heading;
    both file compile using: javac -classpath .\ *.java
    Question 1:
    I cannot run testA by: java -classpath .\ testA
    I think it is a syntax error. What is the correct one?
    If I run testA by: java testA
    The only output I get is: A test
    But I am expecting: B constructor /n A test
    What went wrong?
    Question 2:
    I need to use APIs of another software. I have downloaded a .jar file (xxx.jar) with all the classes in it. And I have put "import xxx.*;" in my source file. But the compiler complains about the importing. What is the right way to copmile it?
    I have read a couple of tutorials but they don't answer my question.
    (I am using windows2000 and don't have the classpath variable.)
    Hope some one can help.
    Thanks a lot

    Try moving testA out of the package and importing 'AB.*;'
    If you have:
    ./testA.class
    ./AB/testb.class
    Then to execute testA from ./ type: java -cp . testA

  • Error while generating JAR files during upgrade from 11.5.9 to 11.5.10

    Hi,
    We are getting the following issue after applying 11.5.9 CU2 patch set during the process of upgrade from 11.5.9 to 11.5.10.
    -     3171663: 11.5.9 Oracle E-Business Suite Consolidated Update 2
    Executing: /u01/app/tinst/tinstcomn/util/java/1.6/jdk1.6.0_18/bin/java -Djava.security.egd=file:/dev/urandom sun.security.tools.JarSigner -keystore ******** -storepass ******** -keypass ******** -sigfile CUST -signedjar /u01/app/tinst/tinstcomn/java/oracle/apps/fnd/jar/fnddssgraphgui.jar.sig /u01/app/tinst/tinstcomn/java/oracle/apps/fnd/jar/fnddssgraphgui.jar.uns CUSTOMER
    ERROR: JarSigner subcommand exited with status 1
    No standard output from jarsigner
    JarSigner error output:
    Exception in thread "main" java.lang.NoClassDefFoundError: sun/security/tools/JarSigner
    Caused by: java.lang.ClassNotFoundException: sun.security.tools.JarSigner
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
    Could not find the main class: sun.security.tools.JarSigner. Program will exit.
    Can you please advice regarding this issue....????
    Regards,
    Sreenivasulu.

    Please see these docs.
    Generate Jar File causes NoClassDefFoundError sun/security/tools/JarSigner [ID 393306.1]
    Generating Jar Files Fails with a NoClassDefFoundError: sun/security/tools/JarSigner Error [ID 801014.1]
    Thanks,
    Hussein

  • Error in deploying .jar file from JDeveloper 10.1.3.5

    Hello,
    I want to deploy .jar file in a machine, instead of having to install JDeveloper to run the application (it contains: Web Services and Data Base).
    I have followed the following steps in JDeveloper to create the .jar file:
    1) Right click over the project: New... --> General (All Technologies option selected) --> Deployment Profiles --> JAR File
    2) I have selected "Include Manifest File" option specifying the application's main class
    3) In JAR Deployment Profile Properties window: File Groups --> Project Output --> Contributors are selected: "Project Output Directory" and "Project Dependencies"
    4) With the previous steps, JDeveloper generates a .deploy file. It is created in Resources folder. From this folder, I have selected the .deploy file and right click and I have selected "Deploy to JAR file"
    The .jar is created succesfully. In this point, I try to execute with the command:
    java -jar NAME_OF_THE_DIRECTORY_WHERE_THE FILEIS_DEPLOYED\NameFile.jar
    and I have the following error:
    Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceFactory
    at project.proxy.AccountClient.<init><AccountClient.java>
    at project.proxy.AccountClient.main<init><AccountClient.java>
    The Manifest File content is:
    Manifest-Version: 1.0
    Created-By: Oracle JDeveloper 10.1.3.5.0
    Main-Class: project.proxy.AccountClient
    I have tested with differents variables to create the .jar file, but always the error is the same. And I haven't found information to solve it. For this reason, I appreciate any help.
    Thank you and regards.
    Edited by: user1634407 on 31-mar-2010 8:27
    Edited by: user1634407 on 31-mar-2010 8:47

    If you are just building a client that access a Web service you need a JAR and not a WAR.
    Ok!
    One thing to try is look at the command line that JDeveloper uses to run your client (it's in the log window) - specifically look at the classpath used.
    Then try and run the same thing from a command line and see if it works.
    Nowadays, the application is running with a .BAT file, it contains the statement released from the JDeveloper console, and it is working perfectlly.
    I try to do the same from a command line, and it works too.
    Assuming it is - you can either use that, or you'll need to make sure that your JAR includes all the mentioned jars that were in the class path - this is done through the library type file group.
    To create the .JAR file I have choosen the following options (JAR Deployment Profile Properties):
    1) Include Manifest File --> I have selected the class that contains the main class (from the Browse option)
    2) I left the default File Groups (Project Output) --> it has: Project Output Directory + Project Dependencies
    3) As you said me, I have created a new File Group (type: Libraries) --> and here, I have selected all the possible Contributors. These match those specified in the project (Oracle XML Parser v2, J2EE, JAX-RPC Client, Commons Logging 1.0.3, Ojdbc14.jar).
    4) Deployment to JAR File successfully.
    The resulting MANIFEST.MF is:
    Manifest-Version: 1.0
    Created-By: Oracle JDeveloper 10.1.3.5.0
    Main-Class: project.proxy.Execution
    It hasn't definied "Class-Path", althought to especified a new File Group with the libraries... Is it an error?
    If I extract the .JAR file, I see all libraries, and I have two folders: one with .class files of my project and other one is META-INF with MANIFEST.MF file.
    5) From command line I executed:
    C:\jdevstudio10135\jdk\bin > java -jar C:\jdevstudio10135\jdev\mywork\project\project\deploy\NameFile.jar
    And the result is an error:
    Exception in thread "main": java.lang.NoClassDefFoundError: javax/xml/rpc/ServiceFactory
    I think the error is because it can not find the library ServiceFactory, but it is especified inside JAX-RPC Client library. What is wrong?
    *6)* I have tried too to insert in "JAR Deployment Profile Properties" (in JAR options) an additional Manifest File to merge into MANIFEST.MF, to include "Class-Path" with all libraries's project (the same JAR from the statement released from the JDeveloper console), but I think that it is a limit, because if I insert all libraries the "Class-Path" doesn't inserted in MANIFEST.MF. The maxim is:
    Class-Path: C:\jdevstudio10135\jdev\mywork\project\project\classes C:\jdevstudio10135\lib\xmlparserv2.jar C:\jdevstudio10135\lib\xml.jar C:\jdevstudio10135\j2ee\home\lib\activation.jar C:\jdevstudio10135\j2ee\home\lib\ejb.jar C:\jdevstudio10135\j2ee\home\lib\jms.jar C:\jdevstudio10135\j2ee\home\lib\jta.jar C:\jdevstudio10135\j2ee\home\lib\mail.jar C:\jdevstudio10135\j2ee\home\lib\servlet.jar C:\jdevstudio10135\webservices\lib\jaxrpc-api.jar
    The following libraries afther the previous one aren't allowed to include because I think that is exceeding the maximum size.
    I have tested to create various MANIFEST.MF with different PATHs libraries, but it isn't work to include in the MANIFEST.MF file all libraries...
    (C:\jdevstudio10135\webservices\lib\wsclient.jar
    C:\jdevstudio10135\webservices\lib\wsserver.jar
    C:\jdevstudio10135\webservices\lib\wssecurity.jar
    C:\jdevstudio10135\webservices\lib\wsdl.jar
    C:\jdevstudio10135\webservices\lib\orasaaj.jar
    C:\jdevstudio10135\webservices\lib\saaj-api.jar
    C:\jdevstudio10135\webservices\lib\orawsdl.jar
    C:\jdevstudio10135\webservices\lib\orawsrm.jar
    C:\jdevstudio10135\webservices\lib\jaxr_api.jar
    C:\jdevstudio10135\webservices\lib\orajaxr.jar
    C:\jdevstudio10135\webservices\lib\relaxngDatatype.jar
    C:\jdevstudio10135\webservices\lib\jaxb-impl.jar
    C:\jdevstudio10135\webservices\lib\jaxb-libs.jar
    C:\jdevstudio10135\webservices\lib\xsdlib.jar
    C:\jdevstudio10135\webservices\lib\mdds.jar
    C:\jdevstudio10135\jlib\jaxen.jar
    C:\jdevstudio10135\jlib\oraclepki.jar
    C:\jdevstudio10135\jlib\ojpse.jar
    C:\jdevstudio10135\jlib\osdt_core.jar
    C:\jdevstudio10135\jlib\osdt_cert.jar
    C:\jdevstudio10135\jlib\osdt_xmlsec.jar
    C:\jdevstudio10135\jlib\osdt_wss.jar
    C:\jdevstudio10135\jlib\osdt_saml.jar
    C:\jdevstudio10135\jlib\repository.jar
    C:\jdevstudio10135\jlib\ojmisc.jar
    C:\jdevstudio10135\j2ee\home\lib\http_client.jar
    C:\jdevstudio10135\j2ee\home\jazncore.jar
    C:\jdevstudio10135\j2ee\home\oc4jclient.jar
    C:\jdevstudio10135\rdbms\jlib\xdb.jar
    C:\jdevstudio10135\diagnostics\lib\ojdl2.jar
    C:\jdevstudio10135\jakarta-taglibs\commons-logging-1.0.3\commons-logging-api.jar
    C:\jdevstudio10135\jakarta-taglibs\commons-logging-1.0.3\commons-logging.jar
    C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14.jar
    C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14_g.jar
    C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14dms.jar
    C:\oracle\product\10.2.0\client_1\jdbc\lib\ojdbc14dms_g.jar)
    With this .MF file (or including only "C:\jdevstudio10135\jdev\mywork\project\project\classes") I have solved the other problem (not found the libraries), but it still not working, the error is a little different:
    Exception in thread "main": java.lang.NoClassDefFoundError: project/proxy/Execution
    The path where the main class is: C:\jdevstudio10135\jdev\mywork\project\project\classes\project\proxy\Execution.class
    I have tried to insert directlly the following paths in "Main Class" option of "Include Manifest File":
    C:\jdevstudio10135\jdev\mywork\project\project\classes\project\proxy\Execution
    C:\\jdevstudio10135\\jdev\\mywork\\project\\project\\classes\\project\\proxy\\Execution
    And with these values, the error is the same: Exception in thread "main": java.lang.NoClassDefFoundError
    I am not sure if the error is a bug of JDeveloper 10.1.3.5 or it is something that I don't correctly. Any idea?
    Thank you again and regards.
    Edited by: user12085357 on 08-abr-2010 1:31
    Edited by: user12085357 on 08-abr-2010 1:38
    Edited by: user12085357 on 08-abr-2010 6:58

  • How to include jar files in ant script for compiling

    i am trying to manually include j2ee.jar for compiling, here is the entire build.xml:
    <?xml version="1.0"?>
    <!--PRIMARY build file for all of dev modual -->
    <project name="com" default="compile.all" basedir="../">
    <path id="project.class.path">
    <pathelement location="lib/"/>
    <pathelement path="${java.class.path}/"/>
    <pathelement path="${additional.path}"/>
    <pathelement path="${CLASSPATH}" />
    <pathelement path="${classpath}" />
    </path>
    <property name="SRCDIR" value="${basedir}/java" />
    <property name="DSTDIR" value="${basedir}/classes" />
    <property name="LIBDIR" value="${basedir}/libs" />
    <property name="JARDIR" value="${basedir}/jars" />
    <property name="DOCDIR" value="${basedir}/docs" />
    <property name="ORACLE.JAR" value="${LIBDIR}/orcl/8.1.7/classes12.zip" />
    <property name="JUNIT.JAR" value="${LIBDIR}/junit/3.7/junit.jar" />
    <property name="CLASSPATH" value="z:/tools/java;${SRCDIR};${DSTDIR};${JUNIT.JAR};${ORACLE.JAR}" />
    <property name="POLICYFILE" value="${SRCDIR}/com/leader/cti/main/ctimain.policy" />
    <property name="DEBUG_FLAG" value="on" />
    <property name="OPTIMIZE_FLAG" value="off" />
    <property name="DEPRECATION_FLAG" value="off" />
    <property name="RMI_VERSION" value="1.2" />
    <!-- builds everything -->
    <target name="compile.all">
    <antcall target="compile.cti"/>
    </target>
    <target name="compile.vbsf" description="Compiles files for vbsf.jar.">
    <mkdir dir="${DSTDIR}"/>
    <copy file="${SRCDIR}/VBSFELK5UD3SWQ2E.class" todir="${DSTDIR}"/>
    <javac srcdir="${SRCDIR}" destdir="${DSTDIR}" classpath="${CLASSPATH}" debug="${DEBUG_FLAG}" deprecation="${DEPRECATION_FLAG}" optimize="${OPTIMIZE_FLAG}" >
    <include name="com/objectmatter/**/*.java" />
    </javac>
    </target>
    <target name="compile.persist" description="Compiles files for persist.jar." depends="compile.vbsf" >
    <javac srcdir="${SRCDIR}" destdir="${DSTDIR}" debug="${DEBUG_FLAG}" deprecation="${DEPRECATION_FLAG}" optimize="${OPTIMIZE_FLAG}" >
    <classpath refid="project.class.path"/>
    <include name="com/leader/persist/**/*.java" />
    <include name="testcom/leader/persist/**/*.java" />
    </javac>
    </target>
    <target name="compile.cti" description="Compiles files for both cti jars." depends="compile.persist,compile.cti.only" />
    <target name="compile.cti.only" description="Compiles files for both cti jars." >
    <javac srcdir="${SRCDIR}" destdir="${DSTDIR}" debug="${DEBUG_FLAG}" deprecation="${DEPRECATION_FLAG}" optimize="${OPTIMIZE_FLAG}" >
    <classpath refid="project.class.path"/>
    <include name="com/leader/cti/**/*.java" />
    <include name="testcom/leader/cti/**/*.java" />
    </javac>
    <rmic classpath="${CLASSPATH}" base="${DSTDIR}" stubversion="${RMI_VERSION}" >
    <include name="com/leader/cti/main/RMICTIService.class" />
    <include name="com/leader/cti/main/RMIConferenceCall.class" />
    <include name="com/leader/cti/main/RMIConferenceCallReservation.class" />
    <include name="com/leader/cti/main/FakeRmiCtiService.class" />
    <include name="com/leader/cti/main/FakeRmiConferenceCall.class" />
    <!--include name="com/leader/cti/main/DerivedQueueReceiver.class"/-->
    </rmic>
    </target>
    <!-- build all dev jars -->
    <target name="jar.all"
    description="Create all jar files"
    depends="jar.vbsf, jar.persist, jar.jeti, jar.service"/>
    <!-- build vbsf.jar -->
    <target name="jar.vbsf"
    description="Create client distribution jar for vbsf code"
    depends="compile.vbsf" >
    <mkdir dir="${JARDIR}" />
    <jar jarfile="${JARDIR}/vbsf.jar"
    basedir="${DSTDIR}" >
    <include name="VBSFELK5UD3SWQ2E.class"/>
    <include name="com/objectmatter/**/*.class" />
    </jar>
    </target>
    <!-- build persist.jar -->
    <target name="jar.persist"
    description="Create client distribution jar"
    depends="compile.vbsf,compile.persist" >
    <mkdir dir="${JARDIR}" />
    <jar jarfile="${JARDIR}/persist.jar"
    basedir="${DSTDIR}" >
    <include name="com/leader/persist/**/*.class" />
    </jar>
    </target>
    <!-- build jeti.jar -->
    <target name="jar.jeti"
    description="Create client distribution jar"
    depends="compile.vbsf,compile.persist,compile.cti" >
    <mkdir dir="${JARDIR}" />
    <jar jarfile="${JARDIR}/jeti.jar"
    basedir="${DSTDIR}" >
    <include name="com/leader/cti/rmiint/*" />
    <include name="com/leader/cti/main/*Stub*" />
    <include name="com/leader/cti/util/**" />
    <include name="com/leader/cti/vru/*" />
    <include name="com/leader/cti/interfaces/*" />
    <include name="com/leader/cti/history/*" />
    <include name="com/leader/cti/autodial/*" />
    </jar>
    </target>
    <!-- build jeti_service.jar -->
    <target name="jar.service"
    description="Create the jar file for the service"
    depends="compile.vbsf,compile.persist,compile.cti" >
    <mkdir dir="${JARDIR}" />
    <copy file="${basedir}/vbsf/cti.schema" tofile="${DSTDIR}/cti.schema" />
    <copy file="${basedir}/vbsf/cti.schema" tofile="/tools/java/com/leader/osapplication/persist/cti.schema" />
    <jar jarfile="${JARDIR}/jeti_service.jar"
    basedir="${DSTDIR}" >
    <include name="com/leader/cti/**" />
    <include name="cti.schema" />
    </jar>
    </target>
    <!-- build jeti.jar, jeti_service.jar -->
    <target name="jar.cti"
    description ="Create client/server jars for cti"
    depends="jar.jeti,jar.service" />
    <!-- clean everything. -->
    <target name="clean">
    <delete dir="${DSTDIR}" />
    <delete dir="${JARDIR}" />
    <delete dir="${DOCDIR}" />
    </target>
    <target name="clean.cti" description="clean cti class files (not jars)">
    <delete dir="${DSTDIR}/com/leader/cti" />
    <delete dir="${DSTDIR}/testcom/leader/cti" />
    </target>
    <!-- Run the gui CTI tests -->
    <target name="test_cti_gui">
    <java classname="junit.swingui.TestRunner" classpath="${CLASSPATH}" fork="yes">
    <arg value="testcom.leader.cti.CTIPackageTest"/>
    <sysproperty key="leader.unique_number_generator.file" value="unique_number_generator_file_test" />
    <sysproperty key="vbsf.repository" value="/tools/java/dev/vbsf" />
    <sysproperty key="vbsf.enableGlobalCaching" value="false" />
    </java>
    </target>
    <target name="test.cti.gui"
    depends="test_cti_gui" />
    <!-- Run the text version of CTI tests -->
    <target name="test">
    <java classname="junit.textui.TestRunner" classpath="${CLASSPATH}" fork="yes">
    <arg value="testcom.leader.cti.CTIPackageTest"/>
    <sysproperty key="leader.unique_number_generator.file" value="unique_number_generator_file_test" />
    </java>
    </target>
    <!-- Run CTI service -->
    <target name="run.service"
    description="run the service normally"
    depends="compile.all" >
    <java classname="com.leader.cti.main.CTIMain"
    classpath="${CLASSPATH}"
    fork="yes" >
    <sysproperty key="java.security.policy"
    file="${POLICYFILE}" />
    <sysproperty key="config.dir"
    value="${SRCDIR}/com/leader/cti/main/" />
    </java>
    </target>
    <!-- Run fake CTI service -->
    <target name="run.service.fake"
    description="run the fake service"
    depends="compile.all" >
    <java classname="com.leader.cti.main.FakeCtiMain"
    classpath="${CLASSPATH}"
    fork="yes" >
    <sysproperty key="java.security.policy"
    file="${POLICYFILE}" />
    <sysproperty key="config.dir"
    value="${SRCDIR}/com/leader/cti/main/" />
    </java>
    </target>
    <!-- Run CTI service emulator -->
    <target name="run.service.emulator"
    description="run the service normally"
    depends="compile.all" >
    <java classname="com.leader.cti.main.CTIMain"
    classpath="${CLASSPATH}"
    fork="yes" >
    <sysproperty key="java.security.policy"
    file="${POLICYFILE}" />
    <sysproperty key="config.dir"
    value="${SRCDIR}/com/leader/cti/main/" />
    <sysproperty key="vru.propertyfile"
    value="emulator.properties" />
    </java>
    </target>
    <!-- Runs the CTI service and emulator -->
    <target name="run.emulator"
    description="run the service and the emulator"
    depends="compile.all" >
    <java classname="testcom.leader.cti.vru.emulator.VRUEmulator"
    classpath="${CLASSPATH}"
    fork="yes" />
    </target>
    <!-- Runs the gui CONCALL testss -->
    <target name="run.gui"
    description="run the concall test gui"
    depends="compile.all" >
    <java classname="testcom.leader.cti.main.SwingClient"
    classpath="${CLASSPATH}"
    fork="yes" >
    <sysproperty key="java.security.policy"
    file="${POLICYFILE}" />
    </java>
    </target>
    <!-- Fires the maptool up. Defaults to CTI`s Schema file. -->
    <target name="maptool" >
    <java classname="com.objectmatter.bsf.mapping.toolgui.MapTool"
    fork="yes"
    classpath="${CLASSPATH}" >
    <sysproperty key="vbsf.repository" value="${basedir}/vbsf" />
    </java>
    </target>
    <target name="javadoc_cti">
    <mkdir dir="${basedir}/docs"/>
    <javadoc packagenames="com.leader.*" classpath="${CLASSPATH}" sourcepath="${SRCDIR}" destdir="${DOCDIR}\cti" author="true" version="true" use="true" windowtitle="Leader CTI API" doctitle="Leader Technologies, Inc" bottom="Copyright &#169; 2005 Leader Technologies Incorporated.<BR>All Rights Reserved." maxmemory="128m">
    <group title="Leader CTI Packages" packages="com.leader*"/>
    </javadoc>
    </target>
    <target name="javadoc_vbsf">
    <mkdir dir="${basedir}/docs"/>
    <javadoc packagenames="com.objectmatter.* " classpath="${CLASSPATH}" sourcepath="${SRCDIR}" destdir="${DOCDIR}" author="true" version="true" use="true" windowtitle="VBSF by ObjectMatter API" doctitle="Leader Technologie, Inc" bottom="Copyright &#169; 2005 Leader Technologies Incorporated.<BR>All Rights Reserved." maxmemory="128m">
    <group title="Objectivity Packages" packages="com.objectmatter.*"/>
    </javadoc>
    </target>
    </project>
    i am getting this:
    compile.all:
    compile.vbsf:
    compile.persist:
    compile.cti.only:
    Compiling 1 source file to C:\Projects\Leader\dev\classes
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:14: package javax.jms does not exist
    import javax.jms.*;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:17: package javax.jms does not exist
    import javax.jms.Queue;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:18: package javax.jms does not exist
    import javax.jms.JMSException;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:19: package javax.jms does not exist
    import javax.jms.Message;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:28: cannot find symbol
    symbol: class MessageListener
    public abstract class BasicMQReceiverAsyncR implements Runnable, MessageListener
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:44: cannot find symbol
    symbol : class QueueConnectionFactory
    location: class BasicMQReceiverAsyncR
    QueueConnectionFactory queueConnectionFactory = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:45: cannot find symbol
    symbol : class QueueConnection
    location: class BasicMQReceiverAsyncR
    QueueConnection queueConnection = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:46: cannot find symbol
    symbol : class QueueSession
    location: class BasicMQReceiverAsyncR
    QueueSession queueSession = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:48: cannot find symbol
    symbol : class QueueReceiver
    location: class BasicMQReceiverAsyncR
    QueueReceiver queueReceiver = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:49: cannot find symbol
    symbol : class TextMessage
    location: class BasicMQReceiverAsyncR
    TextMessage message = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:406: cannot find symbol
    symbol : class QueueConnectionFactory
    location: class BasicMQReceiverAsyncR
    queueConnectionFactory = (QueueConnectionFactory)
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:408: package javax.jms does not exist
    queue = (javax.jms.Queue) jndiContext.lookup(QUEUE_NAME); //queue1 = (javax.jms.Queue)jndiContext.lookup("MyQueue1");
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:433: cannot find symbol
    symbol : variable Session
    location: class BasicMQReceiverAsyncR
    Session.AUTO_ACKNOWLEDGE);
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:447: cannot find symbol
    symbol : class JMSException
    location: class BasicMQReceiverAsyncR
    catch (JMSException e)
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:461: cannot find symbol
    symbol : class JMSException
    location: class BasicMQReceiverAsyncR
    catch (JMSException x)
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:482: cannot find symbol
    symbol : class BytesMessage
    location: class BasicMQReceiverAsyncR
    if (m instanceof BytesMessage)
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:488: cannot find symbol
    symbol : class BytesMessage
    location: class BasicMQReceiverAsyncR
    BytesMessage bytesMsg = (BytesMessage)m;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:488: cannot find symbol
    symbol : class BytesMessage
    location: class BasicMQReceiverAsyncR
    BytesMessage bytesMsg = (BytesMessage)m;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:501: cannot find symbol
    symbol : class QueueSession
    location: class BasicMQReceiverAsyncR
    QueueSession queueSession2 = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:502: cannot find symbol
    symbol : class QueueSender
    location: class BasicMQReceiverAsyncR
    QueueSender queueSender2 = null;
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:510: cannot find symbol
    symbol : variable Session
    location: class BasicMQReceiverAsyncR
    Session.AUTO_ACKNOWLEDGE);
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:514: cannot find symbol
    symbol : class BytesMessage
    location: class BasicMQReceiverAsyncR
    BytesMessage bytesMessage = queueSession.createBytesMessage();
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:523: cannot find symbol
    symbol : variable DeliveryMode
    location: class BasicMQReceiverAsyncR
    DeliveryMode.PERSISTENT,
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:524: cannot find symbol
    symbol : variable DEFAULT_PRIORITY
    location: class com.leader.cti.vru.Message
    Message.DEFAULT_PRIORITY,
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:525: cannot find symbol
    symbol : variable DEFAULT_TIME_TO_LIVE
    location: class com.leader.cti.vru.Message
    Message.DEFAULT_TIME_TO_LIVE);
    C:\Projects\Leader\dev\java\com\leader\cti\msgqueue\BasicMQReceiverAsyncR.java:529: cannot find symbol
    symbol : class JMSException
    location: class BasicMQReceiverAsyncR
    catch (JMSException x)
    26 errors
    C:\Projects\Leader\dev\java\build.xml:34: The following error occurred while executing this line:
    C:\Projects\Leader\dev\java\build.xml:56: Compile failed; see the compiler error output for details.
    BUILD FAILED (total time: 8 seconds)
    my class path is:
    .;C:\Projects\Leader\prototype\jms\build\classes;C:\Projects\Leader\dev\libs\persist.jar;C:\Projects\Leader\dev\classes;%OPENJMS_HOME%\lib;%OPENJMS_HOME%\lib\antlr-2.7.2.jar;%OPENJMS_HOME%\lib\castor-0.9.5.jar;%OPENJMS_HOME%\lib\commons-codec-1.3.jar;%OPENJMS_HOME%\lib\commons-collections-2.1.jar;%OPENJMS_HOME%\lib\commons-dbcp-1.2.1.jar;%OPENJMS_HOME%\lib\commons-logging-1.0.4.jar;%OPENJMS_HOME%\lib\commons-pool-1.2.jar;%OPENJMS_HOME%\lib\concurrent-1.3.4.jar;%OPENJMS_HOME%\lib\derby-10.1.1.0.jar;%OPENJMS_HOME%\lib\jdbc-2.0.jar;%OPENJMS_HOME%\lib\jms-1.1.jar;%OPENJMS_HOME%\lib\jndi-1.2.1.jar;%OPENJMS_HOME%\lib\jta-1.0.1.jar;%OPENJMS_HOME%\lib\log4j-1.2.11.jar;%OPENJMS_HOME%\lib\openjms-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\openjms-common-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\openjms-net-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\openjms-tools-0.7.7-beta-1.jar;%OPENJMS_HOME%\lib\oro-2.0.8.jar;%OPENJMS_HOME%\lib\spice-jndikit-1.2.jar;%OPENJMS_HOME%\lib\xerces-2.4.0.jar;%OPENJMS_HOME%\lib\xml-apis-1.0.b2.jar;%J2EE_HOME%\lib\j2ee.jar;%J2EE_HOME%\lib
    as you can see j2ee.jar is in %J2EE_HOME%\lib, but still doesn't work. can someone help me?

    <property name="messaging.client.jar.path" value="Location in your local drive" />
    <property name="messaging.client.jar.name" value="nameOfYourFile.jar" />

  • Include an in-memory jar file for JSR-199 compilation

    I want to compile a source file in memory, which requires a jar file that is also represented in memory. I used the JavaSourceFromString class recommended in the documentation for the class JavaCompiler and in a demo I found online that shows how to compile sources represented as String in memory. To represent the jar file, I used a similar trick to JavaSourceFromString:
    public class JarJavaFileObjectFromByteArray extends SimpleJavaFileObject {
       * The contents of this jar file.
      private final byte[] contents;
       * Constructs a new JarJavaFileObjectFromByteArray given the name and binary
       * contents of a jar file.
       * @param name the name of this jar file
       * @param contents the contents of this jar file
      public JarJavaFileObjectFromByteArray(String name, byte[] contents) {
        super(newURI(name), Kind.OTHER);
        this.contents = contents;
      ... // code not shown ensures that the URI returned from newURI is of the form,
          // for instance, bytes:///MathConstants.jar, if the name of the jar file is MathConstants.jar
      @Override
      public InputStream openInputStream() throws IOException {
        return new ByteArrayInputStream(contents);
    }However, I do not know how to alert the compiler that this jar file should be on the classpath. I tried this:
    List<String> options = Arrays.asList(" -classpath bytes:///MathConstants.jar ");
    CompilationTask task = compiler.getTask(null, fileManager, null, options, null, compilationUnits);but I get the following error when calling getTask:
    java.lang.IllegalArgumentException: invalid flag: -classpath bytes:///MathConstants.jarI assume there is some way to tell the compiler, "look at the MathConstants.jar file that I am storing in memory when searching the classpath", but I do not know how to do this. I assumed that the options parameter for getTask represents command-line flags that would be passed to the compiler if this were happening on the command line (such as "-cp .", which also does not work), but perhaps this assumption is wrong.

    Hi Bruce,
    I have a question regarding loading a jar file by the compiler to dynamically compile with a source file. I hope you can probably offer me an idea on what has been missing or wrong with the source codes I have written for my application.
    I am using Eclipse compiler to dynamically compile a class. In the class, I want it to make a reference to a jar file for compilation dynamically.
    Here is the source of a test class I wrote:
    import javax.servlet.http.HttpServlet;
    class MyServlet extends HttpServlet {
    }The import statement refers to the class javax.servlet.http.HttpServlet from the jar file C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar placed in the file system.
    In the method called compileClass (shown below), I used the path of the jar file to add to the option -classpath as you suggested.
         private static CompileClassResult compileClass(Writer out, String className, String classSource) {
              try {
                   JavaCompiler javac = new EclipseCompiler();
                   StandardJavaFileManager sjfm = javac.getStandardFileManager(null, null, null);
                   SpecialClassLoader scl = new SpecialClassLoader();
                   SpecialJavaFileManager fileManager = new SpecialJavaFileManager(sjfm, scl);
                   List<String> options = new ArrayList<String>();
                   options.addAll(Arrays.asList("-classpath", "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0\\lib\\servlet-api.jar"));
                   List<MemorySource> compilationUnits = Arrays.asList(new MemorySource(className, classSource));
                   DiagnosticListener<JavaFileObject> diagnosticListener = null;
                   Iterable<String> classes = null;
                   if (out == null) {
                        out = new PrintWriter(System.err);
                   JavaCompiler.CompilationTask compile = javac.getTask(out, fileManager, diagnosticListener, options, classes, compilationUnits);
                   boolean res = compile.call();
                   if (res) {
                        //Need to modify the api to return an array of two elements - one classes and other bytecodes for all classes in the same class file.
                        return CompileClassResult.newInstance(scl.findClasses(), scl.findByteCodes());
              } catch (Exception e) {
                   e.printStackTrace();               
              return null;
         }I also extended the class ForwardingJavaFileManager as you suggested and have it delegated to the StandardJavaFileManager sent to the compiler mentioned in the method compileClass above. The extended class (called SpecialJavaFileManager) is as follows:
    public class SpecialJavaFileManager extends ForwardingJavaFileManager<StandardJavaFileManager> {
         private SpecialClassLoader xcl;
         public SpecialJavaFileManager(StandardJavaFileManager sjfm, SpecialClassLoader xcl) {
              super(sjfm);
              System.out.println("SpecialJavaFileManager");
              this.xcl = xcl;
         public JavaFileObject getJavaFileForOutput(Location location, String name, JavaFileObject.Kind kind, FileObject sibling) throws IOException {
              System.out.println("getJavaFileForOutput");
              MemoryByteCode mbc = new MemoryByteCode(name);
              xcl.addClass(name, mbc);
              return mbc;
         public Iterable<JavaFileObject> list(JavaFileManager.Location loc, String pkg, Set kinds, boolean recurse) throws IOException {
              System.out.println("list ");
            List<JavaFileObject> result = new ArrayList<JavaFileObject>();
            for (JavaFileObject f : super.list(loc, pkg, kinds, recurse)) {
                 System.out.println(f);
                result.add(f);
              return result;
    }I run the application and the result shows that it didn't load the jar file into the memory as expected. From the output (below) I got, it doesn't seem to invoke the method list(...) in the class SpecialJavaFileManager.
    SpecialJavaFileManager
    1. ERROR in \MyServlet.java (at line 1)
         import javax.servlet.http.*;
                ^^^^^^^^^^^^^
    The import javax.servlet cannot be resolved
    2. ERROR in \MyServlet.java (at line 3)
         class MyServlet extends HttpServlet {
                                 ^^^^^^^^^^^
    HttpServlet cannot be resolved to a typeWould you please let me know what has possibly be missing or wrong?
    Thanks.
    Jonathan
    Edited by: jonathanlam on Aug 10, 2009 6:47 PM

  • How to include externel library in JAR file?

    Hi all =)
    I have a program that uses an external library (in a JAR file) I would like to compile my program as a JAR and have it include the external library that it needs to run, so that the external library would not need to be on the computer running my program. How can I do this?
    Thanks =)
    Koneko349
    Message was edited by:
    Koneko349

    Ok I was able to make my JAR and launch my application correctly. However whenever I click a button that has a method using my external library I get the following error:
    C:\Documents and Settings\Koneko>java -jar D:\Mangment.jar
    Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/poi/poifs/filesystem/POIFSFileSystem at managment_system.ManagmentGUI.getNextStat(ManagmentGUI.java:569) at managment_system.ManagmentGUI$1.actionPerformed(ManagmentGUI.java:195)
    I do not get this error when I run and use my program from within the IDE.
    The JAR that has my external library (and has the class for POIFileSystem) is also on my D drive and i referenced it correctly (I think) In my classpath:
    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
         <classpathentry kind="src" path=""/>
         <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
         <classpathentry kind="lib" path="D:/poi.jar"/>
         <classpathentry kind="output" path=""/>
    </classpath>I would really like to get this working and I'm very confused XP

Maybe you are looking for