Include driver in jar file

Hi, i need include de jdbc driver for postgres en my jar application file...
i use netbeans 4 but i dont know make this...
Help meeeeeeeeeeeeeee

It's not just the driver, of course, the driver will connect to every other class in the postgres jar file. You can extract all the files from the jar, creating a directory tree and then combine that tree with your own class tree before building a new jar. If you expand into build/classes then I think the jar target will include them.
"jar xf xxxx.jar" will do the unpacking.
You should also probably take a look at the GenJar project on sourceforge if you're going to do this sort of thing. It's a tool which works out what classes are needed from many sources and assembles them into a jar.

Similar Messages

  • How can I include 3rd party jar files with my custom extention?

    I'm writing an extension that is dependent upon some 3rd party jars. How can I include/package these with my extension?
    we're using the 11g tech preview
    thanks,
    Dylan

    Do you mean that you need these files to appear in JDeveloper as a library available for the developers who build a project and use your extension?
    You can create a library in JDeveloper with JAR files by simply adding the following to your extension.xml file:
    <jdeveloper-hook xmlns="http://xmlns.oracle.com/jdeveloper/1013/extension">
    - <libraries xmlns="http://xmlns.oracle.com/jdeveloper/1013/jdev-libraries">
    <library name="My Extension Library">
    <classpath> ${ide.extension.install.home}/lib/some.jar</classpath>
    </library>
    </jdeveloper-hook>

  • Alternate drives in Jar file Class-Path attribute

    Hello, all. I am working on a project that I would like to package into a single jar file for simple execution. At my place of work classes from EJB are stored on a different drive from where I am doing the development. I am having trouble accessing those classes from the Jars I am creating. When I try the following manifest:
    Main-Class: MyPackage.MyClass
    Class-Path: U:\someFolder
    the application will not start, saying that MyPackage.MyClass cannot be found. This is despite MyPackage.MyClass being properly packaged into the Jar file, as verified by a jar t operation. When I leave off the drive letter in the Class-Path attribute:
    Main-Class: MyPackage.MyClass
    Class-Path: someFolder
    the application starts and executes properly right up until a class from someFolder is needed, at which point exceptions begin to be thrown.
    Any ideas will be much appreciated!
    John Todd

    I was eventually able to find the answer to my own question: Jars do not accept absolute paths at all, only relative paths. Thus, the alternate drive approach will not work. Fortunately I was able to find an alternate solution.
    John Todd

  • How to read a certificate included in a jar-file???

    Hello,
    I have an application who connects via SSL to a JBoss server. Therefore I need a certificate on the client machine.
    Can I include a selfsigned certificate in the jar file which can be downloaded with webstart???
    If that's possible where can I find the certificate??? For now on my machine I use
    System.setProperty("javax.net.ssl.trustStore","c:/Program Files/.../certificate.truststore");
    I suppose I have to change the path, but I have no idee to where???
    Thanks anyway
    Bart

    Write out the trust store to a file in the temp directory on the client machine when your application starts and instruct the java.net classes to use it by setting the system property just like you described.
    note.. I'm just guessing here
    -Spinoza

  • How to include third party .jar files into my jar file

    Hi,
    how do i include a open source third party jar file into an executable jar?
    i have a class called BlogBox.java and it uses org.apache.commons.net.ftp.FTPClient, i want to create an executable file, where do i put the .jar file containing FTPClient aka Apache Commons Net?
    currently i'm getting the following error from when executing my BlogBox.jar
    C:\MyJava\BlogBox>java -jar BlogBox.jar
    Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/net/ftp/FTPClient
    at blogbox.BlogBox.<init>(BlogBox.java:27)
    at blogbox.BlogBox.main(BlogBox.java:103)
    Any suggestions? i have searched google and this forum but could not find the solution to my problem, thanks
    [edited msg] do i need to add the classpath at execution or something of the apache commons net library?
    Message was edited by:
    gekkokid

    When you use an executable jar the normal class path
    is ignored, but you can put a classpath inside the
    jar. The usual trick is to place the library jar
    files in a directory inside the application directory
    and direct the manifest file to it. The manifest file
    live in the jar inside the META-INF directory and
    it's called manifest.mf
    The two heavilly used entries are Main-class: and
    Class-path: lines. Class-path just has a
    comma-separated list of library paths.
    The jar utility has a special option to load it up.Thanks :) I created a "/lib" directory, placed in the packages in there and redirected the Class-Path: lib/commons-net-1.4.1.jar
    and it works,
    thank you everyone :)

  • Creating jar file including 2 another jar files

    hi
    My project has java files, properties files,batch files as well as two jar files,mail.jar & activation.jar(for importing packages).
    I have to include these jar files while setting environment variables.
    Now i want to make "MyPrj.jar" file for myproject ,can anyone pls help me how to include these all files into a single jar file. and how to make setup file
    I have tried to extract out .class files of mail.jar & activation.jar & i ve created MyPrj.jar by including all class files(including class files of mail.jar & activation.jar) but manifest file(headers) are not added to MyPrj.jar.
    i have also tried to give mail.jar & activation.jar in Class-Path of menifest file, but it is also not working.
    Pls Help
    Thanks a lot

    [http://sourceforge.net/projects/one-jar]
    "One-JAR(TM) is a simple solution to a vexing problem in Java: how to distribute an application as a single jar-file, when it depends on multiple other jar-files. One-JAR uses a custom classloader to discover library jar files inside the main jar. "

  • [noob] how to include third part jar file in ear

    Hi,
    eveything is in the subject. It's quartz that I'm using btw.
    Regards
    Fred

    Hello,
    You are using the internal deployment file?
    <yourapp>.deploy?
    1) Place the file in the WEB-INF/lib directory
    2) Right click <yourapp>.deploy file and select properties
    3) File Groups -> WEB-INF/Lib -> Contributers and select your jar file.
    4) Rebuild the ear, done
    -Anton
    PS Be carefull, depending on the Application server you are using the quartz library COULD already be present (Most have it) and this could be a different version!
    If this is the case you need to tell the application server to load classes from the web-inf directory first!
    With the Oracle OC4J containers this can be done during deployment, classloaders and select search local classes first.
    With Weblogic you will need the deployment descriptor 'weblogic.xml' and add:
    <container-description>
    <prefer-web-inf-classes>true</prefer-web-inf-classes>
    </container-description>

  • How to include an external jar file in .EAR project

    Hello All,
    I have created a web service through java class in sap netweaver 7.1.
    For database connection i want to add external jar file as reference. could you all please tell me how to do this or can i get some scenario where it is explained.
    Please Help
    Regards,
    Vanita Jain

    Hi Vanita,
    open your project in nwds > right click on the project > click on properties option from the menu > click on java build path from the left-side navigation of the window > and click on libraries in the right side tab > here you'll get a button called add external jars > clicking to this, will open browser window to select a jar file.
    Regards,
    Sen

  • Unable to load database driver from my applet's jar file

    I'm trying to set up an applet that will talk to a MySQL database. I have no problem connecting to the database as I'm developing the code ("un-jarred"), but when I create a jar file of my code to test through a web browser, I cannot connect to the database due to the usual ClassNotFoundException. I have included mysql-connector-java-3.1.12-bin.jar (the current driver) in the jar, but I don't know if I'm supposed to supply some info through an attribute to the applet tag to let it know that the jar contains the driver it needs or if I have to call the driver differently in my code.
    Any help is appreciated, thanks.

    The simplest approach is always the best. :)Abso-lutely.
    Awesome, that worked perfectly. I Included the extra
    jar file in the applet tag and now my applet makes
    some sweet lovin' to the database.And you have succeeded where thousands have failed. Congratulations.

  • JDBC driver is not working in JAR file

    Hello
    Java is new for me.
    In my project JDBC is working fine for MSSQL Server 2000. It is developed in Netbeans.
    Now When I am going to rin JAR file of project, Driver for MSSQL is not found.
    Can anyone tell me that What I have to do to work with MSSQL driver in JAR file of project?
    I am using "Microsoft SQL Server 2000 Driver for JDBC" for JDBC.

    In my project JDBC is working fine for MSSQL Server
    2000. It is developed in Netbeans.
    Now When I am going to rin JAR file of project,
    Driver for MSSQL is not found.
    Can anyone tell me that What I have to do to work
    with MSSQL driver in JAR file of project?
    I am using "Microsoft SQL Server 2000 Driver for
    JDBC" for JDBC.Adding the JAR to the Netbeans project means adding it to the classpath for the IDE only, the JAR which you developed still needs the driver jar in the classpath.

  • Recommended way to open a text file included in a jar?

    Forgive me if this seems like an ignorant question, but I keep reading two different things about loading resources in the javadocs and forums, and can't seem to connect them...
    Say you want to open a text file and read the contents into a String or a List. Apparently, the preferred way to do this is something like:
    fileName = "myFile.txt";
    BufferedReader br = new BufferedReader(new FileReader(new File(fileName)));
    String line;
    while ((line = reader.readLine()) != null) {...}
    Now say you want to distribute your app in a jar file, with the text file included in the jar file. The above method won't work, because a FileReader operates on a File, and as I understand it, once myFile.txt is packed into the jar file, it's no longer a "file".
    So what do you do? I keep reading that the best way to open the jarred text file is to use something like this:
    InputStream is = getClass().getResourceAsStream(fileName);
    Here's where I get confused: InputStream, and all of its subclasses, are now supposedly dispreferred for reading character data (in preference to Reader, as above). But no subclass of Reader can wrap around an InputStream, which would facilitate the reading of character data greatly, with methods like readLine().
    So my question is: What's the best way to read a text file from within a .jar?
    Thanks,
    Gregory

    great! glad it's working
    here is a statement from the javadoc
    http://java.sun.com/j2se/1.4.2/docs/api/java/io/InputStreamReader.html
    For top efficiency, consider wrapping an InputStreamReader within a BufferedReader. For example:
    BufferedReader in
    = new BufferedReader(new InputStreamReader(System.in));
    kind regards
    Waken16

  • How to includ jar files?

    Hi,
    I am having jar file and iam running that jar file in command prompt using java -jar WorkFlow.jar command. I have to include some additional jar files in classpath while running this WorkFlow.jar file... Anyone please tell me how to include the jar files in java command??
    Thanks,
    Sathish

    Sathishkumar.D wrote:
    Hi,
    I am having jar file and iam running that jar file in command prompt using java -jar WorkFlow.jar command. I have to include some additional jar files in classpath while running this WorkFlow.jar file... Anyone please tell me how to include the jar files in java command??
    Thanks,
    SathishYou can't. The WorkFlow.jar you have them specified in the class path entry in the manifest file.

  • Including multiple jar files to applet

    In one of my application I am using severla third party apis (JavaHelp, JFreeReport, NanoXml ...) which comes as a seperate jar file each.
    Is there is a way that I can include these multiple jar files to be downloaded automaticaly when the applet is starting.
    currently I am extracting all the jar files and then re compressing them in to one file and place it in the archive property in the applet tab.
    Is there a way I can avoid extraction and recompression and directly use the jar files

    <param nama="archive" value="myjar.jar, myOtherjar.jar" />
    You could try to create an installer that wil put the 3rd party jars in the users lib/ext directory.

  • How to Insert a Text File in a jar file?

    Hi!,
    I have a program which runs smoothly both from the IDE and also from the .jar file when it is on the Hard Disk. When i copied everything onto a CD, the .jar file runs but when it comes to access a text file it pops up the message, which should pop up when a FileNotFoundException is encountered. Now i am using relative paths, in fact i tried to load the whole thing from a pen drive and it works fine as well. I think that if the text file is included in the jar file itself, it might work from the CD as well, but i dont know how to do it. can anyone pls tell me how i can solve this problem?
    Thx in advance, Spi_Mlt

    OK this might give you some trouble (gave me trouble for a long time) so I will try to help you.
    1. in your code load the file as a resources not a FileObject or a local stream, this is what I mean...
    A_stream_that_best_fits_your_needs = getClass().getResourceAsStream("fileName");
    // something like that...if you don't know streams google it2. put a copy of your text file in the same folder as the .java file that loads it and a copy where the .class file that loads it (if they are in the same directory then it just easier than for you).
    3. when compiling the jar include the text file in it!
    Hope that helps!

  • Crystal Report not works in JAR File

    I'm using Eclipse All in one, which includes Crystal Reports.. I Connected my Java program with Crystal Reports and its working properly. Now my problem is that the Report is not working in JAR files.. It throws some exception as
    "com.crystaldecisions.sdk.occa.report.lib.ReportSDKException: com.businessobjects
    com.businessobjects.reports.sdk.JRCCommunicationAdapter---- Error code:-2147215357 Error code name:internal"
    Whats the Error.. I don't know. I think that i may missed some CLASSPATH Files. The included CLASSPATH Files are:
    ReportViewer.jar
    jrcerom.jar
    Concurrent.jar
    CrystalCharting.jar
    CrystalCommon.jar
    CrystalContentModels.jar
    CrystalExporters.jar
    CrystalExportingBase.jar
    CrystalFormulas.jar
    CrystalQueryEngine.jar
    CrystalReportEngine.jar
    CrystalReportingCommon.jar
    icu4j.jar
    keycodeDecoder.jar
    log4j.jar
    MetafileRenderer.jar
    rasapp.jar
    rascore.jar
    rpoifs.jar
    Serialization.jar
    URIUtil.jar
    xercesImpl.jar
    xml-apis.jar
    and the mysql-connector jar file
    Anybody help me please...

    Unable to load database connector
    'com.crystaldecisions.reports.queryengine..driverImpl.
    DriverLoader
    now you have any idea.. pleaseIs that a typo where you have two periods below?
    queryengine..driverImplOther than that I don't think anybody here can help you with that. If your classpath includes all necessary JAR files and you are able to access all your resources from within your application JAR file, then I imagine there is a problem with the third-party crystal decisions JAR file or how you are attempting to use it.
    My advice to you is to try and contact support with the vendor or provider of this API or possibly try posting on a support forum on their website to see if somebody can help you there.

Maybe you are looking for