0

I'm attempting to export a jar file containing the ojdbc14.jar, to allow execution outside of my machine. I can do so successfully with the current export of my jar, but only on my computer, when others try it fails with the error: java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver when it attempts to call Class.forName

I have seen many similar questions on SO concerning this, but none of the questions seem to have the exact problem, and the solutions aren't working either.

Class:

InputStream inputStream = JdbcConnection.class.getClassLoader().getResourceAsStream("properties/jdbc.properties");

    try {

        PROPERTIES.load(inputStream); //Load the jdbc properties


        //System.out.println(properties.getProperty("jdbc.driverClassName"));  <-- this prints out the correct output`
        Class.forName(PROPERTIES.getProperty("jdbc.driverClassName")).newInstance(); //Load the oracle driver

Manifest: (my ojdbc14.jar is located in lib, but the jar will only work on my local machine if just "ojdbc14.jar" is included, the other jars don't have an issue with the path provided, not sure if that is important)

Manifest-Version: 1.0
Main-Class: JdbcConnection
Class-Path:  lib/ojdbc14.jar ojdbc14.jar extrsrcs/kxml2-2.3.0.jar extrsrcs/xstream-1.4.2.jar src/properties/jdbc.properties

UPDATE:

This question better explains how I resolved my issue, as it was related to Jar-within-Jars, executable jars, and etc.

4

1 回答 1

1

I didn't think you could include other jars within a jar (that is what your trying to do isn't it?) I suspect it's working on your machine because ojdbc14.jar is on your classpath somewhere (ie. as the standalone file, rather than included in your jar)

Hope this helps Nathan

于 2012-06-11T20:01:47.137 回答