Results 1 to 2 of 2
  1. #1
    Boomn4x4 is offline Member
    Join Date
    Nov 2011
    Posts
    1
    Rep Power
    0

    Default Could not find Main Class

    I'm developing on Linux SUSE... I'm pretty green to Java. I'm writing a Java application to interface with an OpenEdge v10 database. I'm trying to use the JDBC drivers to do so.

    I have a VERY simple Java application setup, all I'm trying to do is simply load the driver and connect to the database. (I'm sure once I get that far, I'll be good to go with the rest of Java as I am familar with C/C++) What I'm finding in the OpenEdge documentation is that there is a fairly significant difference between using the JDBC drives with OpenEdge 9 vs. 10... and I'm getting confused. Bottom line...my app is getting runtime errors that I'm not really sure how to go about addressing.

    Here is the code that I'm using:
    Java Code:
    import java.net.URL;
    import java.sql.*;
    import java.io.*;
    import java.util.Properties;
    
    public class ProgressTest
    {
        public static String dbUrl = "jdbc:datadirect:openedge://stdblprovwv:6012;DatabaseName=cis";
        public static Connection con = null;
    
    	public static void main (String args[])
    	
    	{
    		try 
    		{
    
    			// Load the driver
    			Driver dbDriver = (Driver)Class.forName("com.ddtek.jdbcx.openedge.OpenEdgeDataSource").newInstance();
    			Properties props = new Properties();
    			props.put("user", "cis");
    			props.put("password", "");
    			con = dbDriver.connect(dbUrl, props);
    		}
    		catch (Exception e)
    		{
    		    e.printStackTrace();
    
    			System.out.println("Error: " + e.getMessage());
    		}
    	}
    }
    I'm sure these pieces of information are more suited for OpenEdge developers, but I'll give them to you anyway... in case they help. The OpenEdge documentation says I need to include the CLASSPATH environment to point to the location of my JDBC drivers, which are located in my /fiscal/dlc/java/lib directory.

    When I execute the application prior to loading the supposed enviroment CLASSPATH, I get the following output:
    Java Code:
    mxb931@mxbscs:~/queue/java> java ProgressTest
    java.lang.ClassNotFoundException: oracle.jdbc.driver.OracleDriver
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    	at java.lang.Class.forName0(Native Method)
    	at java.lang.Class.forName(Class.java:169)
    	at ProgressTest.main(ProgressTest.java:33)
    Error: oracle.jdbc.driver.OracleDriver
    It looks to me there that it simply cannot find the OpenEdge driver, and throws an excpetion saying so.

    Following the documentation and adding my CLASSPATH variable, I get a different output:
    Java Code:
    mxb931@mxbscs:~/queue/java> java ProgressTest
    Exception in thread "main" java.lang.NoClassDefFoundError: ProgressTest
    Caused by: java.lang.ClassNotFoundException: ProgressTest
    	at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    	at java.security.AccessController.doPrivileged(Native Method)
    	at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    	at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    	at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
    Could not find the main class: ProgressTest.  Program will exit.
    Here it appears that it cannot find the defined class in the first place... Why can't it find the main class... when the main class is the program itself?

    Thank you for your help.

  2. #2
    Shoss's Avatar
    Shoss is offline Member
    Join Date
    Feb 2011
    Posts
    94
    Rep Power
    0

    Default Re: Could not find Main Class

    Are you still having trouble with this? It seems like it should work. Is it possible ProgressTest.class no longer exists in ~/queue/java or the CLASSPATH somehow no longer contains "." (current directory)?

Similar Threads

  1. Could not find the main class
    By RudeOil in forum New To Java
    Replies: 1
    Last Post: 10-13-2011, 10:37 PM
  2. Could not find the main class:
    By Kareng in forum JavaServer Pages (JSP) and JSTL
    Replies: 3
    Last Post: 10-01-2011, 09:04 AM
  3. Could not find or load main class BubbleSort.class
    By blaqkout in forum New To Java
    Replies: 5
    Last Post: 09-12-2011, 08:54 PM
  4. Could not find main class
    By Andyj in forum New To Java
    Replies: 2
    Last Post: 10-06-2009, 01:47 AM
  5. Could not find main class - JDK 1.6
    By Syranno in forum New To Java
    Replies: 1
    Last Post: 07-25-2008, 05:07 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •