0

I am unable to execute a JAR file from the command line. It is returning a ClassNotFoundException and is referencing the database driver class. The application runs fine within Netbeans.

C:\temp> java -classpath C:\Temp\db2jcc.jar;C:\Temp\CatalystIncomingWire.jar -jar .\CatalystIncomingWire.jar file.txt

C:\temp> java -classpath .\db2jcc.jar -jar .\CatalystIncomingWire.jar file.txt

java -jar .\CatalystIncomingWire.jar file.txt

Code that loads the driver

        //Create DB2 connection
        Class.forName("com.ibm.db2.jcc.DB2Driver");        
        Connection conn = DriverManager.getConnection("jdbc:db2://keystone:50000/"+db,"user","pass");      

It will read a file and output a new one. Works fine within netbeans.

Jim Garrison
  • 85,615
  • 20
  • 155
  • 190
SQL B
  • 121
  • 5
  • According to the documentation you have to include `db2jcc4.jar` in your classpath as well. – Jim Garrison Apr 24 '19 at 02:24
  • I thought that's what i was doing? At least in the first two examples. Is that not the correct way to include a classpath? – SQL B Apr 24 '19 at 16:08
  • There are ***two*** jar files, `db2jcc.jar` and `db2jcc4.jar`. – Jim Garrison Apr 24 '19 at 16:27
  • java -classpath .\db2jcc.jar .\db2jcc4.jar -jar .\CatalystIncomingWire.jar .\324172575IncomingDomestic04182019.txt Error: Could not find or load main class .\db2jcc4.jar – SQL B Apr 24 '19 at 16:31
  • When I add a semicolon between the two jar files it doesn't accept it, I just get the helplist – SQL B Apr 24 '19 at 16:32
  • 1
    You cannot use `-classpath` and `-jar` on the same command line. Please refer to the manual entry for the `java` command. (And the dup Q&A) – Stephen C Apr 25 '19 at 03:03

0 Answers0