PLEASE HELP: NASTY COMPILE & RUN TIME ERRORS!!!

Discussions

General J2EE: PLEASE HELP: NASTY COMPILE & RUN TIME ERRORS!!!

  1. PLEASE HELP: NASTY COMPILE & RUN TIME ERRORS!!! (3 messages)

    Hi everyone,

    I keep getting the following 3 errors:

    1)When I try to run my class "MainScreen.java" which is a GUI:

    C:\Proj\code>java project_gui\MainFrame
    Exception in thread "main" java.lang.NoClassDefFoundError: project_gui\MainFrame
     (wrong name: project_gui/MainFrame)
            at java.lang.ClassLoader.defineClass0(Native Method)
            at java.lang.ClassLoader.defineClass(Unknown Source)
            at java.security.SecureClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.defineClass(Unknown Source)
            at java.net.URLClassLoader.access$100(Unknown Source)
            at java.net.URLClassLoader$1.run(Unknown Source)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.net.URLClassLoader.findClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClass(Unknown Source)
            at java.lang.ClassLoader.loadClassInternal(Unknown Source)

    2)When I try to compile another class I am told that a certain line make reference to a deprecated part of the Java library. The Java code it is referring to is:

    "DriverManager.registerDriver(new oracle.jdbc.driver.OracleDriver());"

    I have been searching all over the Java API and the net, but still cannot find out what this line should be changed to.

    3)Lastly, I am also told that "String(byte[], int)" has been deprecated, but again I cannot find a suitbale replacement.

    Please, please can somebody help, as I am at my wits end!!!

    Many thanks!
  2. What does the class package look like? It should be:

    package project_gui;

    Also, the public class needs to be the same name as the filename, so either MainFrame needs to be in MainFrame.java, or you need to run java project_gui\MainScreen.
  3. With the above package definition, try:

    java -cp "C:\Proj\code" project_gui.MainFrame
  4. That won't work if the only source file is MainScreen.java will it?

    I thought the JVM will only look for "public static void main(String args[]) {}" in the primary class, i.e. MainScreen?

    Col