CLASSPATH and JDBC Drivers in a Jar File

Hi all, I am creating an application in JDev that uses JDBC to connect to a 10g database. I am deploying my application to a jar and running it on the database server using the jdk installed with the database. $ORACLE_HOME/jdk/bin I want to also use the jdbc driver installed in $ORACLE_HOME/jdbc/lib instead of including the driver in my application jar file. How can I cause my jar file to find the jdbc lib?
Can I register it directly with the DriverMannager using the file? My app knows the $ORACLE_HOME.
Or do I just include the jdbc driver in my jar?
John

I was hoping it would be that easy. But I am still having problems. Here is my setup.
export MON_JAVA="$ORACLE_HOME/jdk/bin/java -classpath /u01/app/oracle/product/10.2.0/db_1/jdbc/lib/ojdbc14.jar"
$MON_JAVA -jar PMonitor.jar -c trace
and I get this error when connecting to the database.
Exception in thread "main" java.lang.NoClassDefFoundError: oracle/jdbc/OracleDriver
I also tried the classes.jar with the same results.

Similar Messages

  • Any difference in the dbms and jdbc drivers btw oracle 8i lite and 9i lite

    Is there any significant difference between oracle 8i lite and oracle 9i lite in terms of database and jdbc drivers?
    If not, it may be better off using oracle8i.

    According to Oracle , 9i lite is more powerful than 8i Lite.
    one thing, 8i Lite is not certified for windows 2000.
    jothi

  • JAR files for SQLJ and JDBC drivers: what is the best practice?

    starting a migration from IAS 10 to WebLogic 11g.
    Apparently the jar files for SQLJ are not on the classpath by default.
    java.lang.NoClassDefFoundError: sqlj/runtime/ref/DefaultContextwhich is the better practice: putting the SQLJ runtime jar into the lib subdirectory of the domain directory, or using a shared library reference? (usage of SQLJ is pretty prevalent in our apps, though we may be getting away from it)
    are the Oracle JDBC drivers on the classpath by default?
    if not, then the same question: put them into the lib subdirectory of the domain directory, or use a shared library reference?

    I'm looking at the setDomainEnv, especially the big note at the top:
    >
    # WARNING: This file is created by the Configuration Wizard.
    # Any changes to this script may be lost when adding extensions to this configuration.
    >
    and am getting squeamish about editing it...
    http://www.bea-weblogic.com/how-do-i-disable-wls-automatically-adding-to-classpath.html looks like the default behaviour is for WebLogic to put $DOMAIN/lib;$WL_HOME/common/lib/ext;$WL_HOME/server/lib/ext on the classpath; there is also a reference to setting weblogic.ext.dirs= when starting weblogic (which means I set the WEBLOGIC_EXTENSION_DIRS environment variable).
    http://download.oracle.com/docs/cd/E12840_01/wls/docs103/programming/libraries.html#wp1067450 also refers at the bottom to using the domain /lib subdirectory.
    so am I correct that a good practice is to just put the jars I think I will globally need into $DOMAIN/lib, rather than putting them in $WL_HOME/common/lib/ext, $WL_HOME/server/lib/ext, or fiddling with the WEBLOGIC_EXTENSION_DIRS environment variable?
    Edited by: user8652010 on Feb 10, 2011 1:08 PM

  • Installing ODBC and JDBC drivers

    I have recently downloaded JDBC drivers from the Oracle driver download page.
    How do I install them?

    JDBC drivers aren't generally "installed" in the standard sense. They're just JAR files-- you put them in your CLASSPATH and you're done.
    For ODBC drivers, you need to install the Oracle client, then you can use the Oracle Universal Installer that's part of the client install to install the latest ODBC driver patchset.
    Justin

  • Problems with classpath and oracle drivers

    Hi, i've developed an application that uses oracle drivers "classes12.jar" using Eclipse. While i was writing the code, i manually specified the classpath which contains "classes12.jar" file using Eclipse's own configuration tool and now it works perfect when i run it under Eclipse. I then tried to run it using dos prompt but when i tried to run the program i got "ClassNotFoundException: oracle.jdbc.driver.oracledriver". As you can guess, i thought that was a classpath issue so i set the classpath as follows:
    set CLASSPATH=C:\oracle\ora92\jdbc\lib
    where the directory "C:\oracle\ora92\jdbc\lib" is the one that contains classes12.jar file which i had also specified using Eclipse before.
    After that, i recompiled my application and tried to launch it as follows:
    ->javac Test.java
    ->java Test
    But then i got the following runtime error:
    Exception in thread "main" java.lang.NoClassDefFoundError: Test
    Since this happened after i manually set CLASSPATH variable, this has something to do with that. What should i do now? Thanks in advance.

    Correct - the JAR has to be spelled out in the CLASSPATH.
    I'd also recommend that you not set CLASSPATH using a system environment variable. Better to use the -classpath parameter on javac.exe when you compile and java.exe when you run. Put the command into a script that you invoke when you start up the app. It'll document the fact that it's needed for anyone that comes after you and relieves you from having to change the CLASSPATH on machines you deploy to. And, for good measure, app servers like Tomcat and WebLogic totally ignore the system CLASSPATH. I don't even have one.
    %

  • I am getting the following error: Unable to locate class: java.lang.NoClassDefFoundError: on an iPlanet WS. We have ensured that the classpath in jvm12.conf includes the jar file with path. Any ideas?

     

    Well, now I'm pulling my hair out even more because I can't get it to resolve anything in jaxws-rt.jar at runtime. Note: compile-time still works FINE.
    I was messing with classpaths and stuff (and the endorsed dirs option of course) and it was "working" to the extent I had posted before, but then I kept playing with it and at some point I said, this isn't working and I need to reset all this stuff back to the way it was.
    ... so I did that. And now it won't resolve "PolicyException:"
    java.lang.NoClassDefFoundError: com/sun/xml/ws/policy/PolicyException
    This doesn't mean anything to you guys I bet, but that happens when it FIRST gets inside the web service code, which references PolicyException (doesn't even use it at that point.. I'm assuming the import is screwing it up when it's in the constructor). So now it won't resolve at all. Before, it was getting past this point and telling me the "method not found" error on the next line or this same error for WSBindingProvider two lines down, when it's actually being used. AWESOME.
    I downloaded the latest jaxws-rt.jar and all its dependencies, shoved that into my lib folder, and set the endorsed dir to that folder (There's kind of a web of dependencies here. jaxws-rt.jar expects all its dependencies to be in the same folder, it seems, so I don't know how it was "working" before when I just copied jaxws-rt.jar into my separate endorsed dir - but I can't move all of those files to endorsed because I need them in my project (which expects them to be in the lib folder)). What happened? It went back to my original "String" error (first error in the first post), which means it's not getting endorsed at all from that location.
    What a mess.
    Can someone tell me what the heck I'm supposed to do with this jar file?

  • Classpath is not working for executable jar file

    I have created executable jar file using following command where manifest file contains Main-Class and Class-Path entries.
    jar cvfm app.jar META-INF/* lib/* *.class
    So here app.jar contains my external jar's in lib directory
    but when I move app.jar to another directory, it's doesn't get my external files.
    I'm not getting this problem as these jar's are in app.jar
    class-path entry in manifest file:
    Class-Path: lib/abc.jar lib/xyz.jar
    Pls help me where it is getting fail?
    Thanks in advance,
    Vikas

    Java doesn't handle jars within jars. Your library jars need to be outside of the executable jar as in
    dist - main.jar
          - lib  -  lib1.jar
                 -  lib2.jar

  • How do I load property files and images stored in the jar file?

    Hi
    So, if I have a structure like this:
    /com.myfirm.myproject.SomeClass
    /images/
    /properties/
    And I pack this structure into a jar file, how do I then access the images under "/images/" and the property files under "/properties/"? A link to a good tutorial on this would be perfect, or a description/hint/howto :)

    Im having problems even loading direcly from the directory..? I have this structure:
    src (source dir)
    classes (classes dir)
    lang/textRb_en_US.properties (the file I want to load)
    Then I have this code:
    Locale currentLocale = new Locale("en", "US");
    ResourceBundle textRb = ResourceBundle.getBundle("/lang/textRb", currentLocale);But it gives me a "java.util.MissingResourceException: Can't find bundle for base name /lang/textRb, locale en_US". I start my application from within Eclipse, and I have tried to move "lang/textRb_en_US.properties" into the classes dir, but same error.
    Im confused as to there Java looks for ressources, and I need this to work no matter where I put my classes/jar. Could you help me out here?

  • Problem deploying and using custom Tags in jar files

    I am trying to create a custom tag library of Java classes, package them in a JAR file, and use them in another web application. Here is the JAR file structure, named mytags.jar:
    META-INF
    META-INF/manifest.mf
    META-INF/taglib.tld
    mytags/FooBar.class
    mytags/Another.class
    ...Here is the taglib.tld file:
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    <taglib xmlns="http://java.sun.com/ns/j2ee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee web-jsptaglibrary_2_0.xsd"
    version="2.0">
       <tlib-version>1.0</tlib-version>
       <short-name>foo</short-name>
       <uri>fooTags</uri>
       <info>My tags</info>
       <tag>
         <name>fooBar</name>
         <tag-class>mytags.FooBar</tag-class>
         <body-content>empty</body-content>
         <attribute>
           <name>name</name>
           <required>false</required>
           <rtexprvalue>true</rtexprvalue>
         </attribute>
      </tag>
    </taglib>The FooBar class has getName(String) and setName() methods.
    In the web application, I have copied mytags.jar into the WEB-INF/lib directory. I've verified that it lands in the corresponding directory for my appserver (I'm using Tomcat 6.0.10).
    Here's the header for my JSP:
    <%@ page language="java" contentType="text/html;charset=UTF-8" %>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
    <%@ taglib uri="fooTags" prefix="foo" %>
    <foo:fooBar name="dummy" />
    ...When I access my page, the browser sits there and spins, not able to do anything. I know that some of the content is executed, but it is not able to get to the fooTags. I have tried replacing fooTags with WEB-INF/lib/mytags.jar, to no effect.
    According to the docs, I should not need to include anything in web.xml to reference the fooTags. The tag library classes are valid, since I used them as local tags prior to moving them into a Jar library.
    Any help would be appreciated

    Take the code of the jsp file :
    <%@ page language="java" %>
    <%@ taglib uri="WEB-INF/struts-html.tld" prefix="html" %>
    <html>
       <head>
         <title> First Struts Application </title>
       </head>
         <body>
            <table width="500" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td> </td>
            </tr>
            <tr bgcolor="#36566E">
              <td height="68" width="48%">
                <div align="left">
                  <img src="images/hht.gif" width="220" height="74">
                </div>
              </td>
            </tr>
            <tr>
             <td> </td>
            </tr>     
           </table>
           <html:form action="Lookup"
                      name="lookupForm"
                      type="wiley.LookupForm" >
           <table width="45%" border="0">
            <tr>
              <td>Symbol:</td>
              <td><html:text property="symbol" /> </td>
            </tr>
             <tr>       
              <td colspan="2" align="center"><html:submit/> </td>
             </tr>       
            </table>              
          </html:form>
         </body>
    </html>

  • When I search using my address bar it comes up and say page not found jar file, how do I fix this?

    File not found
    Firefox can't find the file at jar:file:///C:/Program Files (x86)/Mozilla Firefox/omni.jar!/chrome/en-US/locale/browser-region
    Check the file name for capitalization or other typing errors.
    Check to see if the file was moved, renamed or deleted.

    hello Kygirl, please install the search reset addon - it will revert the most common customziations those adware programs do in firefox back to the default (including the keyword search from the location bar): https://addons.mozilla.org/firefox/addon/searchreset/

  • Bundling all java,html and even images in a jar file

    Hi All,
    When i bundle all my application .java files in a jar along with manifest i give something as,
    jar -cvf Name.jar manifest.txt *.classMy question is if i want to bundle even couple of HTML and even some images like(jpg,png..etc)..How should i do that???
    Thanks in advance.
    regards,
    Viswanadh

    Follow the instructions here:
    [http://java.sun.com/docs/books/tutorial/deployment/jar/index.html]
    Note that if you want to run the html. it must be outside of the jar, not in it.

  • MTS and JDBC drivers

    I having trouble getting MTS to work with 8.1.5 on solaris, I think the problem might be that my clients are using the JDBC thin drivers (in classes111.zip). Should this work?

    Yes, but what made me suspect JDBC was the doc says the listener sends back a "reconnect" to tell the client to reconnect to the selected dispatcher. I wasn't sure this was working, since LSNRCTL> SERVICES indicated connections going to the dispatchers but I was getting connect errors back from the JDBC library. Another odd thing is LSNRCTL> SERVICES shows two entries for my service -- both with the same name. The first has a dedicated server only, and the second has a dedicated server and dispatchers.

  • Netbeans and JDBC drivers

    try {
            String driver = "com.mysql.jdbc.Driver";
            Class.forName(driver).newInstance();
    catch( Exception e ) {
            System.out.println("Failed to load the mysql driver");
            return;
         }This code works fine when run outside netbeans, ie. from the command line because my classpath includes the appropriate JDBC driver. When I use the code in netbeans it throws the exception. Why does it do this when my system classpath is set correctly?

    i have exactly the same problem. none of the 4 replies here earlier than this has offered any help. will anyone who knows please help? put in another way, the question is "how do you get your j2se application to connect to a database from within netbeans using jdbc? netbeans have tutorial for a web application connecting with jdbc, but none for j2se application!!!! wonderful! i thought the philosophy was to keep simple things simple and difficult things possible, and i would have thought it should be simple for a j2se app to connect to a dbase. can anyone from netbeans probably reading this please show us how?

  • Question about classpath and jar file

    I have a jar file (actually jhall.jar, the java help jar file). How do I uses its classes if I don't want to add it to the classpath. Currently, I have the jar file in the same directory as all my other classes.

    it simply adds secondjar.jar into firstjar.jar, rather
    than extracting secondjar.jar's files and put it into
    firstjar.jar. How would I be able to do that?Don't do either of them. Distribute the two jar files separately, and in the manifest of the one which is meant to be your executable jar file, put a Class-Path: entry that refers to the other one. Look at the latter parts of the tutorial about jar files:
    http://java.sun.com/docs/books/tutorial/jar/basics/
    PC&#178;

  • How to create and use library JAR files with command-line tools?

    Development Tools -> General Questions:
    I am trying to figure out how to put utility classes into JAR files and then compile and run applications against those JAR files using the command-line javac, jar, and java tools. I am using jdk1.7.0_17 on Debian GNU/Linux 6.0.7.
    I have posted a simple example with one utility class, one console application class, and a Makefile:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130520-2134.tar.gz
    Here is a console session:
    2013-05-20 21:39:01 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-20 21:39:12 dpchrist@desktop ~/sandbox/java/jar
    $ cat src/com/example/hello/HelloConsole.java
    package com.example.hello;
    import static com.example.util.Hello.hello;
    public class HelloConsole {
        public static void main(String [] args) {
         hello("world!");
    2013-05-20 21:39:21 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -f hello
    find . -name '*.class' -delete
    javac src/com/example/util/Hello.java
    javac -cp src src/com/example/hello/HelloConsole.java
    echo "java -cp src com.example.hello.HelloConsole" > hello
    chmod +x hello
    2013-05-20 21:39:28 dpchrist@desktop ~/sandbox/java/jar
    $ ./hello
    hello, world!I believe I am looking for:
    1. Command-line invocation of "jar" to put the utility class bytecode file (Hello.class) into a JAR?
    2. Command-line invocation of "javac" to compile the application (HelloConsole.java) against the JAR file?
    3. Command-line invocation of "java" to run the application (HelloConsole.class) against the JAR file?
    I already know how t compile the utility class file.
    Any suggestions?
    TIA,
    David

    I finally figured it out:
    1. All name spaces must match -- identifiers, packages, file system, JAR contents, etc..
    2. Tools must be invoked from specific working directories with specific option arguments, all according to the project name space.
    My key discovery was that if the code says
    import com.example.util.Hello;then the JAR must contain
    com/example/util/Hello.classand I must invoke the compiler and interpreter with an -classpath argument that is the full path to the JAR file
    -classpath ext/com/example/util.jarThe code is here:
    http://holgerdanske.com/users/dpchrist/java/examples/jar-20130525-1301.tar.gz
    Here is a console session that demonstrates building and running the code two ways:
    1. Compiling the utility class into bytecode, compiling the application class against the utility bytecode, and running the application bytecode against the utility bytecode.
    2. Putting the (previously compiled) utility bytecode into a JAR and running the application bytecode against the JAR. (Note that recompiling the application against the JAR was unnecessary.)
    (If you don't know Make, understand that the working directory is reset to the initial working directory prior to each and every command issued by Make):
    2013-05-25 14:02:47 dpchrist@desktop ~/sandbox/java/jar
    $ cat apps/com/example/hello/Console.java
    package com.example.hello;
    import com.example.util.Hello;
    public class Console {
        public static void main(String [] args) {
         Hello.hello("world!");
    2013-05-25 14:02:55 dpchrist@desktop ~/sandbox/java/jar
    $ cat libs/com/example/util/Hello.java
    package com.example.util;
    public class Hello {
        public static void hello(String arg) {
         System.out.println("hello, " + arg);
    2013-05-25 14:03:03 dpchrist@desktop ~/sandbox/java/jar
    $ make
    rm -rf bin ext obj
    mkdir obj
    cd libs; javac -d ../obj com/example/util/Hello.java
    mkdir bin
    cd apps; javac -d ../bin -cp ../obj com/example/hello/Console.java
    cd bin; java -cp .:../obj com.example.hello.Console
    hello, world!
    mkdir -p ext/com/example
    cd obj; jar cvf ../ext/com/example/util.jar com/example/util/Hello.class
    added manifest
    adding: com/example/util/Hello.class(in = 566) (out= 357)(deflated 36%)
    cd bin; java -cp .:../ext/com/example/util.jar com.example.hello.Console
    hello, world!
    2013-05-25 14:03:11 dpchrist@desktop ~/sandbox/java/jar
    $ tree -I CVS .
    |-- Makefile
    |-- apps
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.java
    |-- bin
    |   `-- com
    |       `-- example
    |           `-- hello
    |               `-- Console.class
    |-- ext
    |   `-- com
    |       `-- example
    |           `-- util.jar
    |-- libs
    |   `-- com
    |       `-- example
    |           `-- util
    |               `-- Hello.java
    `-- obj
        `-- com
            `-- example
                `-- util
                    `-- Hello.class
    19 directories, 6 filesHTH,
    David

Maybe you are looking for

  • Best way to use Sage 50 Accounts on an iMac

    I currently have an iMac and would like to run Sage 50 Accounts on it. Sage is not Mac compatible and so needs to run from a Windows environment. I know this is possible and am aware of the following options: 1. Install Windows via Bootcamp and use a

  • Addenda Records in ACH file

    Hello All, I have generated  ACH file to transmit it to the bank for making payments to our vendors.I am using ACH payment method format D with CCD payment mthod using PMW, not RFFOUS* program.Now my client wants to put additional details in the ACH

  • Officejet 6500A plus - paper wads up from bottom roller when copier is activated

    when printer is activated, paper wads up when it begins going from the supply to the printer.

  • Program crashes on ref assignment (no funtion call)

                final Block b = design;     // NullPointerExceptionMay be the problem is the fact that the method belongs to an inner sub-calss located in enclosing sub-class. The design field is declared in a super- enclosing class. But project compiles

  • Smooth way to restart failed R3loads with table splitting

    Hi, We are running a Unicode conversion with largest tables split into 10 or more export/import packages. Now some of the packages fail, as they normally do. We use sockets technique. Do you find a smooth and reliable way to - delete already imported