1

I have developed a Windows MS Access Java app with Netbeans V6.1 Everything works okay in the IDE including loading the MS Access data into a jTable. When I run it from the Windows command line, the app starts but the data is not loaded into the jTable. Instead, I get pages of errors, but the first few are:

java -jar doactions.jar
Picked up _JAVA_OPTIONS: -Xmx512M
Jan 28, 2016 12:22:21 AM doactions.DoActionsView <init>
SEVERE: null
java.lang.ClassNotFoundException: sun.jdbc.odbc.JdbcOdbcDriver
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)

doActions is the app and DoActionsView is the where the jTable is. It seems that the build does not see the MS Access database defined in the ODBC Manager. Can anyone please offer any help?

Gord Thompson
  • 98,607
  • 26
  • 164
  • 342
  • Have your app display the string returned by `System.getProperty("java.version")`. Does it by chance refer to "1.8" (Java 8) when you run it from the Windows command prompt? – Gord Thompson Jan 28 '16 at 21:41

3 Answers3

0

You need to make sure that the JDBC ODBC driver jar is in your class path.

Jason
  • 11,258
  • 3
  • 39
  • 46
0

Sorry that I did not see the question from Gord Thompson.

The version of Java whch is displayed at the java prompt and the runtime version of the app is 1.8.0_45 but from the Netbeans IDE is 1.6.0_45. I assume I have somehow installed different versions of run time java and the JDK. As Netbeans is happy to run the 1.6 version, I will firstly reinstall run time 1.6 version to see if this fixes the problem.

I had two versions of java installed on my laptop. I have now removed the 1.8 version and everything works fine. Many thanks

Lawrence

0

When launching the app from the command prompt it was running under a Java 8 (1.8.0_45) JVM (Java Virtual Machine) and when running the app in NetBeans it was running under Java 6 (1.6.0_45). That explains the difference.

The command-prompt invocation was running under the Java Runtime Environment (JRE) registered with the operating system. Oracle currently distributes Java 8 when you download the JRE from java.com.

NetBeans was running that same application under Java 6 because it was using a Java 6 JDK (Java Development Kit). NetBeans was launching its Java environment from the JDK, not the stand-alone JRE.

As for why the app would work under Java 6 and fail under Java 8, the JDBC-ODBC Bridge has been removed from Java 8 and is no longer available. For an alternative that does work with Java 8, see

Manipulating an Access database from Java without ODBC

Community
  • 1
  • 1
Gord Thompson
  • 98,607
  • 26
  • 164
  • 342