Referencing a JAR archive

Hello forum, this question has probably been asked a thousand times but I can?t seem to find a answer.
I have a java package installed a C:\Program File\CSoftware\Import\Classes.jar
In my code (C:\Java_Code), how do I make a reference to this package so that I can use its contents?
Thanks very much,
Harold Clements

I am really confused now.....
I will start again. I have a 3rd party package installed at the following location: :\Program File\CSoftware\Import\Classes.jar
I am using the command line to try and compile. I don?t know how the reference the classes.jar packages in my own java code.
The example given to me above (1st reply) uses [import mypackage.*]. I would like to know (from the path I have given) what I would used in place of mypackage.
I take it (from the 4th reply) that when I have a compiled class I need to used the ?cp [path] [filename] command.
Thanks everyone for your help.

Similar Messages

  • How to use database file within jar archive

    Hi. I'm quite new in Java programming, and I'm wondering if what I did makes sense or not.
    In my applet I'm using a MS Access Database file, which is contained in the same Jar Archive like the Applet class file. I tried and tried to use this Database file directly but it wouldn't work. Than I read in some other forum that it is not possible to use the database file directly within the archive. First question: Is that true?
    Than I desided to extract the DB file in the init() method of my applet to the default temporary foulder. When the program is closed I use the destroy() method to delete it again. Everything works well now. But is this the typical way this is done?
    Thanks for help!

    Hi,
    here is the code which extracts the database file out of the jar archive (the same archive in which the class file is):
    //get the user temporary folder
    File TempFolder = new File(System.getProperty("java.io.tmpdir"));
    //create (empty) db file
    efile = new File(TempFolder, "steelSections.mdb");
    // if database file is not yet extracted
    if (!efile.exists()) {
    //get an input stream for the database file
    InputStream in = new BufferedInputStream(this.getClass().getClassLoader().getResourceAsStream(
    "FaST/db/steelSections.mdb"));
    //create an output stream for the db file on the file system
    OutputStream out = new BufferedOutputStream(new FileOutputStream(efile));
    //-Buffer to copy the data
    byte[] buffer = new byte[2048]; //buffer to copy the binary
    for (;;) {
    int nBytes = in.read(buffer); //read data
    if (nBytes <= 0)
    break; //no more data to read
    out.write(buffer, 0, nBytes); //write data
    out.flush(); //close out and in streams
    out.close();
    in.close();
    If you have the db file in an other jar archive file you need a referenze to the entry in the other jar archive. I'm not sure how to get this, but I'm sure you fill find a solution by searching in this forum...
    Good luck!

  • Load a file stored in a Jar Archive

    Dear all,
    I have a text file stored in a Jar Archive and I want to obtain a File instance of the text file from the jar file. The reason for this is because I have a method which read in a File instance of the file.
    From my understanding, one can obtain an byte[] array from a file stored in a text file. Is there a way to convert the byte[] into a File instance?
    Thanks.
    Sunny

    Once again, thank you for your prompt response. I agree that one can obtain an inputstream of a file from the Jar archive and work with it. The problem that I am having is that the method that I have is not written by me, to be precise, I am using Syslog and try to read in a configuration file packed in a Jar Archive. The Syslog library only provide a method, which only accept a 'File' instance as an input argument.
    Thanks.
    Sunny

  • Problems with JApplet, jar-Archive, packages and IE5

    Hello!
    I have a problem with a JApplet and Internet Explorer 5. I made a jar archive of my classes. The classes are
    members of a package. The jar archive also contains images.
    The structure of the archive:
    com/mycomp/myapp/DemoApplication.class
    com/mycomp/myapp/DemoApplet.class
    <more classes>
    com/mycomp/myapp/images/hp_logo.gif
    com/mycomp/myapp/images/test.gif
    <more images>
    The archive is stored locally in a directory which contains also the html file.
    I used the sdk 1.3.1 to compile the classes.
    My problem: when I start the html file on NT with IE5, I get the error message below:
    I try to create a label containing an icon with:
    topLabel.setIcon(new javax.swing.ImageIcon(getClass().getResource("images"+fs+"hp_logo.gif")));It works on Sun with Netscape 4.67 and SDK 1.3.1 installed.
    Should I move the images directory inside the jar archive to another place or is the html code not correct?
    The error message:
    java.lang.NullPointerException
         at javax.swing.ImageIcon.<init>(Unknown Source)
         at com.mycomp.myapp.DemoApplication.initComponents(DemoApplication.java:158)
         at com.mycomp.myapp.DemoApplication.<init>(DemoApplication.java:55)
         at com.mycomp.myapp.DemoApplet.<init>(DemoApplet.java:24)
         at java.lang.Class.newInstance0(Native Method)
         at java.lang.Class.newInstance(Unknown Source)
         at sun.applet.AppletPanel.createApplet(Unknown Source)
         at sun.plugin.AppletViewer.createApplet(Unknown Source)
         at sun.applet.AppletPanel.runLoader(Unknown Source)
         at sun.applet.AppletPanel.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)The html file:
    <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
    <html>
      <head>
        <title>DemoApplet</title>
      </head>
      <body>
    <BODY LINK="#0000ff" VLINK="#800080" BGCOLOR="#37a1a7">
          <h1>DemoApplet</h1>
          <!--"CONVERTED_APPLET"-->
    <!-- HTML CONVERTER -->
    <SCRIPT LANGUAGE="JavaScript"><!--
        var _info = navigator.userAgent; var _ns = false; var _ns6 = false;
        var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);
    //--></SCRIPT>
    <COMMENT><SCRIPT LANGUAGE="JavaScript1.1"><!--
        var _ns = (navigator.appName.indexOf("Netscape") >= 0 && ((_info.indexOf("Win") > 0 && _info.indexOf("Win16") < 0 && java.lang.System.getProperty("os.version").indexOf("3.5") < 0) || (_info.indexOf("Sun") > 0) || (_info.indexOf("Linux") > 0) || (_info.indexOf("AIX") > 0) || (_info.indexOf("OS/2") > 0)));
        var _ns6 = ((_ns == true) && (_info.indexOf("Mozilla/5") >= 0));
    //--></SCRIPT></COMMENT>
    <SCRIPT LANGUAGE="JavaScript"><!--
        if (_ie == true) document.writeln('<OBJECT classid="clsid:CAFEEFAC-0013-0001-0000-ABCDEFFEDCBA" WIDTH = 695 HEIGHT = 525  codebase="http://java.sun.com/products/plugin/1.3.1/jinstall-131-win32.cab#Version=1,3,1,0"><NOEMBED><XMP>');
        else if (_ns == true && _ns6 == false) document.writeln('<EMBED type="application/x-java-applet;jpi-version=1.3.1"  CODE = com.mycomp.myapp.DemoApplet CODEBASE = "." ARCHIVE = "DemoApplet.jar,classes12.zip" WIDTH = 800 HEIGHT = 600  scriptable=false pluginspage="http://java.sun.com/products/plugin/1.3.1/plugin-install.html"><NOEMBED><XMP>');
    //--></SCRIPT>
    <APPLET  CODE = com.mycomp.myapp.DemoApplet CODEBASE = "." ARCHIVE = "DemoApplet.jar,classes12.zip" WIDTH = 695 HEIGHT = 525></XMP>
    <PARAM NAME = CODE VALUE = com.mycomp.myapp.DemoApplet >
    <PARAM NAME = CODEBASE VALUE = "." >
    <PARAM NAME = ARCHIVE VALUE = "DemoApplet.jar,classes12.zip" >
    <PARAM NAME="type" VALUE="application/x-java-applet;jpi-version=1.3.1">
    <PARAM NAME="scriptable" VALUE="false">
    </APPLET>
    </NOEMBED></EMBED></OBJECT>
    <!--
    <APPLET CODE = DemoApplet CODEBASE = "." ARCHIVE = "DemoApplet.jar,classes12.zip" WIDTH = 695 HEIGHT = 525>
    </APPLET>
    -->
    <!--"END_CONVERTED_APPLET"-->
      </body>
    </html>Thank you for your help!
    Gruesse,
    Torsten

    seems like it couldn't find the image file... try to give it the absolute path to the file first to see if this is the root of the problem... and then try to find alternative ways to not give it the absolute path...

  • How to create/read/write textfiles in a jar archive?

    Hi!
    I would like to know how to create, read and write text file in a jar file?
    //Marcus

    You want to update "files" that are inside a jar archive? You can't. At least not very easily; to modify a file you need to create a new version of the jar, copy over everything else, and add the new version of that file. Look for a different design that doesn't require updating a jar.
    PC&#178;

  • How to play wave files from a jar archive?

    Dear friends,
    I have a .jar archive with several .wav files, and I would like to play them without extract these files.
    This is possible to do? If yes, please show me how to do this.
    Thank you for your attention,
    Augusto Nunes

    This discussion of getResource is very useful: http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html#getresource

  • Creating one jar archive out of several jar archives

    I have a problem with jar files. What i am trying to do is:
    Build one jar archive out of several jar archives. But i always get a ZipException. I opened a JarOutputStream and tried to write JarEntry objects to the stream by using the putNextEntry() method.
    here my code:
    // finalJar is the file to with i want to write
    // final Manifest is the manifest for that jar archive
    try {
    fout = new FileOutputStream (finalJar);
    jout = new JarOutputStream(fout,finalManifest);
    } catch (IOException io) { // log }
    // curJar ... is the current jar archive as JarFile Object
    Enumeration entries = curJar.entries();
    while (entries.hasMoreElements()) {
    JarEntry curEntry = (JarEntry) entries.nextElement();
    try {
    jout.putNextEntry(curEntry);
    } catch (ZipException ze) { // log}
    I get this error: (for every entry the same error !)
    java.util.zip.ZipException: invalid entry size (expected 6010 but got 0 bytes)
    at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:188)
    at java.util.zip.ZipOutputStream.putNextEntry(ZipOutputStream.java:116)
    at java.util.jar.JarOutputStream.putNextEntry(JarOutputStream.java:90)
    at GenerateData.createFinalJARArchive(GenerateData.java:361)
    at GenerateData.run(GenerateData.java:87)
    at GenerateData.main(GenerateData.java:72)
    I hope you can help me
    Thanks in advance
    Stefan Siegl

    while((c=in.read())>=0) jout.write(c);I guess you mean with '>' the bigger as '>' char
    .right ?Yes, the "greater than" sign.
    Just a standard stream copying procedure.
    >
    I use your code and set the compression to compressed
    jout.setMethod(ZipOutputStream.DEFLATED);
    jout.setLevel(8);
    jout.putNextEntry(curEntry);
    what i get is this exception:
    java.util.zip.ZipException: invalid entry compressed
    size (expected 787 but got 786 bytes)
    at
    java.util.zip.ZipOutputStream.closeEntry(ZipOutputStrea
    .java:193)
    at
    at
    at
    t
    GenerateData.createFinalJARArchive(GenerateData.java:51
    at GenerateData.run(GenerateData.java:89)
    at GenerateData.main(GenerateData.java:73)
    So there is one byte missing! But i dont know where
    ?!It seems one can't reuse the entry.
    Try to create a new one:
    //jout.putNextEntry(curEntry);
    jout.putNextEntry(new ZipEntry(curEntry.getName()));And I think it's a bad idea to try to change
    the compression level between the entries.
    At list untill you haven't got it working somehow.
    >
    But i finally want to do is to store the entries (and
    the data) uncompressed but if i read byte by byte
    there would not a uncompression, would it ?No. You read the data uncompressed.
    here I also got an exception, indicating that the read
    size was invalid.
    Exception when doing it like this:
    jout.setMethod(ZipOutputStream.STORED);
    jout.setLevel(0);The setLevel(0) is redundant here.
    jout.putNextEntry(curEntry);
    is:
    java.util.zip.ZipException: invalid entry compressed
    size (expected 2805 but got
    6015 bytes)
    at
    at
    at
    t
    java.util.zip.ZipOutputStream.closeEntry(ZipOutputStrea
    .java:193)
    at
    at
    at
    t
    GenerateData.createFinalJARArchive(GenerateData.java:51
    at GenerateData.run(GenerateData.java:89)
    at GenerateData.main(GenerateData.java:73)
    I hope someone can help me with that
    Regards
    Stefan Siegl
    So my variant is:
    jout.setMethod(ZipOutputStream.STORED);
    while (entries.hasMoreElements()) {  
       JarEntry e=(JarEntry) entries.nextElement();  
       //write the appropriate entry to jout
       jout.putNextEntry(new ZipEntry(curEntry.getName()));
       //copy the actual data to jout  
       InputStream currIn=curJar.getInputStream(e);  
       int c;  
       while((c=in.read())>=0) jout.write(c);  
       currIn.close();
    }Hope we finally took over.

  • Creating WAR/ JAR archives

    Hi, This appears to be a silly question but would appreciate any help on this.
    I am new to WEblogic Workshop and have created some portal appns. I want to create
    a WAR archive and also a JAR archive in another case. However the build menu of
    the workshop only provides an option for generating a EAR archive.
    I perused the help topics but couldnt find the soln.. Would appreciate any help
    on this.
    I also have another question regarding building .class files. When I add a new
    Java file to a Project, How can I compile only that particular class ?? When I
    try to compile the file, the entire project gets compiled taking huge amt of time..
    thnx in adv,
    sg

    SG,
    Unfortunately there is no option to generate .war files from within workshop in the current release.
    Workshop uses a split source directory structure when building projects.
    Regarding the question on Java class compilation what type of project are you adding the java source file to ?
    Cheers
    -Raj

  • Can I refer to a file insider a .JAR archive with an instance of File?

    Hi,
    I was wondering if it is possible to refer to a file stored inside a .JAR file just as if it was on a regular folder by using an instance of the java.io.File class. Otherwise, how can one do that?
    Essencially what I need is to check if a particular class file is contained inside a .JAR archive.
    Best regards,
    Norberto

    http://java.sun.com/j2se/1.4.2/docs/api/java/util/jar/JarFile.html
    See the entries() method to get a list of everything in the jar file. Most of the time the only thing you would want to do with a File is read the bytes from it, which you can do easily using the JarFile class.

  • Sign jar archive

    Hi everybody!
    I hope that's the right forum :)
    I have a jar archive and i wan to sign it with jarsigner. The problem is, that I want to use a certificate and private key, that were not created with keytool.
    Both are in a pkcs12 file.
    Aaaaaaaaaaaand another question: If you change the content of a signed jar archive, the jar will not start anymore? Is that right?
    Thanks for help!

    If you change the content of a signed jar archive, the jar will not start
    anymore? Is that right?You sign a jar to make sure noone changes the content of the jar.
    Changing the content of the jar means you have to resign it.
    To convert your p12 to jks you can have a look at this:
    http://mark.foster.cc/kb/openssl-keytool.html

  • Use classes from a jar archive from in a jar archive

    Hi, I am making a program and I need some the classes in a certain jar archive for tehm to work. Well my program workes before I add it to a jar be when I make it into one and put the needed jar in it, the program breaks. So does anyone know how to access the class of the jar in my jar?

    Well my program workes before I add it to a jar be when I make it into one and put the needed jar in it, the program breaksIt might be easier not to nest the jar files. Instead make the "needed" jar part of the class path when you make your jar file's manifest.
    [http://java.sun.com/docs/books/tutorial/deployment/jar/downman.html]

  • How to extract a jar archive.

    I am in Windows XP SP3,
    using the command line to try and extract a jar archive, to it's present directory:
    jar -xv experiment.jarThe computer just sits there for ages, apparently caught in a loop,
    issuing no output.
    How may I meet with more success?

    Zac1234 wrote:
    jar -xv experiment.jar
    jar -xvf experiment.jar

  • Access wav-files in jar-archives (URL works, File works not)

    Hi there!
    The un-jar-ed application works fine, but I have a problem with accessing files in jar archives.
    URL url = Classname.class.getResource("testdir/test.wav");works fine (and loading images works this way), but as soon as I try to get the file
    File file = new File(url.getFile());I get an null-exception.
    (in my case, I use the jmf package to play the sound-files, and I get the problem when I try to instatiate the MediaLocator
    MediaLocator mediaLocator = new MediaLocator(url);but I think the problem is the same)
    Thanx for help

    works fine Then keep doing it that way. What's the problem? It's true that you can't access something in a jar archive via a File object, so don't do that.

  • Using a java jar archive in PL SQL

    Hello, where I can find information about How can I use a java jar archive in PL SQL?
    Or How can I do it?
    Thanks in advance!

    Depends on your version. I recommend starting here: Oracle® Database Java Developer's Guide. This is the 11.2 version. If you are on a different version I recommend you read that instead. You can find it at http://tahiti.oracle.com

  • OCF jar archive

    To use secure applets with OCF, among other things, a Jar archive of OCF has to be created on the local machine.
    Has someone an idea how this OCF archive is created? Do I have to use the "jar" command on the whole "C:\OpenCard" directory or do I have to choose specific files?
    Thank you!

    what are you talking about ? OCF already has everything in a jar, you don't have to rebuild the archive unless you are modifying something. And as with all archives, of course they have to exist on the client, otherwise, how will it run ?

Maybe you are looking for

  • Picked Quantity to be made equal to Delivery Quantity in VL02n

    Hello Experts, Have a requirement, where upon when entering in VL02n with a delivery no, the Picked Quantity field (LIPSD-PIKMG) should be equal to Delivery Quantity (LIPS-LFIMG). Only the exit USER_EXIT_READ_DOCUMENT  of include MV50AFZ1 is being ca

  • Creation of DB Adaptert for calling stored procedure in MS SQL server

    Hi, I need to create a DB adapter to call a stored procedure in MS SQL Server. I have gone thru the thread MS SQL Server database connection It mentions that we need to use a command line utility for generating the wsdl and xsd for calling stored pro

  • Script Errors in TOC from RoboHelp 9

    Hello, all. I can usually find the answer to my problems by searching existing threads, but I can't seem to find a solution this time. I recently upgraded from RoboHelp 7 to 9.0.2.271. I have published WebHelp locally and then checked files in to a T

  • Newbie question: Select one row from table in PL/SQL

    Hi, I want to select one row from the table Employee where Emplyoyee Number is say 200. This is a simple SQL query, but I don't know the equivalent PL/SQL format. I will have 3 out params here - Id itself, Name, Salary. I will then have to populate a

  • Error parsing report

    Hi all, I'm having trouble getting the Ant task working in Linux.   The swf runs, but there seems to be an issue communicating back the test results.  I pasted a full dump of the ant output below.  I've tried it in both Fedora 8 and OpenSUSE 11.2, an