Page 1 of 2 12 LastLast
Results 1 to 20 of 28
  1. #1
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Question Dreaded java/lang/NoClassDefFoundError

    Hi,
    Although this post strikes a resemblance to the JonBrand post - I did conduct a search and read all similar threads but none seemed to match my problem.

    I installed the JDK SE (version 6 update 21) on a Windows XP Pro SP3 desktop PC. My JAVA_HOME environment variable is set to c:\program files\java\jdk1.6.0_21 and my Path variable is set to c:\program files\java\jdk1.6.0_21\bin;...

    If I type "java -version" I get a proper message identifying the version JDK 1.6.0_21. However if I type "javac" ; instead of getting the usage and syntax screen, I get:

    "Error occurred during initialization of VM
    java/lang/NoClassDefFoundError: java/lang/Object"

    My "classpath" environment variable is set to ".".

    When I check the JRE directory the rt.jar files is indeed there.
    I originally had JBuilder 5 installed a long time ago but I removed all installed Java environments before I downloaded SDK 6 Update 21.
    Since I've had the problem I have completely removed all Java from my machine and re-installed the SDK 3 times. Twice with update 21 and once with update 19 (based on advice I read in another forum). I must say that I had a lot of difficulty removing JBuilder 5. Both the uninstall program and the Windows Add or Remove both seem to head off into Never land. My fear is that my registry is somehow corrupted - but I thought I'd get a second opinion. Does anyone know where am I going wrong with my install procedure?

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,039
    Rep Power
    20

    Default

    So what is the full javac command you are using, just to check there's nothing blindingly obvious in that...not that I can think of something offhand.

  3. #3
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default My command line

    I usually go to my source directory and call the compiler from there:
    "c:>\prog\java_tmp> javac HelloWorldApp.java"

  4. #4
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default my source and the ...\java directory

    Volume in drive C is PC_AMD64
    Volume Serial Number is B4B3-B575

    Directory of C:\Program Files\Java

    [.] [..] [j2re1.4.1_02] [jdk1.6.0_21] [jre6]
    test.txt
    1 File(s) 0 bytes
    5 Dir(s) 38,413,619,200 bytes free


    My test program is simply:

    /**
    * The HelloWorldApp class implements an application that
    * simply prints "Hello World!" to standard output.
    */
    public class HelloWorldApp {

    /** Creates a new instance of HelloWorldApp */
    public HelloWorldApp() {
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String[] args) {
    System.out.println("Hello World!"); // Display the string.
    }
    }

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,039
    Rep Power
    20

    Default

    Didn't think it would be the javac, since that error is the JVM having trouble.

    How did you unistall the prior java version? You say add/remove had trouble...I suspect you could be right about your registry, since that's often a sign something's up.

    I'm wondering if it's looking for the old rt.jar?

  6. #6
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    Well as I say, I used Add or Remove Programs in the My Computer screen. I only had trouble with the JBuilder 5 Personal removal - in fact it is still listed in the list of current programs. JBuilder is similarly present in the All Programs list accessed from the Start button. However the JRE and JSE items were removed without any problems.

  7. #7
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    I fear that I may need to do a re-install of my Windows XP - trouble is that it was dealer installed - and I have no CD! I see a Windows Vista or Windows 7 upgrade in my future. Neither prospect instills me with enthusiasm...

  8. #8
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by javaNeophyte View Post
    Volume in drive C is PC_AMD64
    Volume Serial Number is B4B3-B575

    Directory of C:\Program Files\Java

    [.] [..] [j2re1.4.1_02] [jdk1.6.0_21] [jre6]
    test.txt
    What are those two different JREs doing there? Normally there is a separate JRE for the user and an identical one is needed for the JDK; my bet would be to remove everything and reinstall again.

    kind regards,

    Jos

  9. #9
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    OK - "in for a penny - in for a pound!" I'll try to remove evrything once more and update my environment variables (if necessary).

    By the way - thanks to you and Tolls for your help.

  10. #10
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default Removed and re-installed jdk1.6.0_21 & jre6

    I Removed jre6 and jdk1.6.0_21 and downloaded them again - re-installed and get the same error as before. Checked the environment variables classpath = ".", JAVA_HOME = "c:\program files\java\jdk1.6.0_21
    path: blah blah blah; c:\program files\java\jdk1.6.0_21\bin.:confused:

  11. #11
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by javaNeophyte View Post
    I Removed jre6 and jdk1.6.0_21 and downloaded them again - re-installed and get the same error as before. Checked the environment variables classpath = ".", JAVA_HOME = "c:\program files\java\jdk1.6.0_21
    path: blah blah blah; c:\program files\java\jdk1.6.0_21\bin.:confused:
    Can you show a directory listing of your \Program Files\Java directory again?

    kind regards,

    Jos

  12. #12
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    Volume in drive C is PC_AMD64
    Volume Serial Number is B4B3-B575

    Directory of C:\Program Files\Java

    10/04/2010 02:19 PM <DIR> .
    10/04/2010 02:19 PM <DIR> ..
    10/04/2010 01:27 PM <DIR> jdk1.6.0_21
    10/04/2010 01:16 PM <DIR> jre6
    10/04/2010 02:19 PM 0 new.txt
    1 File(s) 0 bytes
    4 Dir(s) 37,943,123,968 bytes free

  13. #13
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by javaNeophyte View Post
    Volume in drive C is PC_AMD64
    Volume Serial Number is B4B3-B575

    Directory of C:\Program Files\Java

    10/04/2010 02:19 PM <DIR> .
    10/04/2010 02:19 PM <DIR> ..
    10/04/2010 01:27 PM <DIR> jdk1.6.0_21
    10/04/2010 01:16 PM <DIR> jre6
    10/04/2010 02:19 PM 0 new.txt
    1 File(s) 0 bytes
    4 Dir(s) 37,943,123,968 bytes free
    That looks good; now remove the environment variables JAVA_HOME and CLASSPATH and try to compile a simple Java program again (leave your PATH variable as it is).

    kind regards,

    Jos

  14. #14
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    Removed JAVA_HOME classpath, and checked that they were undefined. OK.
    Now issued "javac HelloWorldApp.java" from within my c:\prog\java_tmp directory which is home to the test java source code. Same problem.

  15. #15
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by javaNeophyte View Post
    Removed JAVA_HOME classpath, and checked that they were undefined. OK.
    Now issued "javac HelloWorldApp.java" from within my c:\prog\java_tmp directory which is home to the test java source code. Same problem.
    There is something wrong in your JRE (or JDK) installation. Is there a file lib\rt.jar present both in your jre6 directory as well as your jdk\jre directory? (there are two Java Runtime Environments, one for you and one for the jdk).

    kind regards,

    Jos

  16. #16
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    There is a file rt.jar (43 MB) in jre6\lib, but there is no rt.jar file in my jdk\lib directory.
    Here is the listing for jdk1.6.0_21\lib:

    Volume in drive C is PC_AMD64
    Volume Serial Number is B4B3-B575

    Directory of C:\Program Files\Java\jdk1.6.0_21\lib

    10/04/2010 03:34 PM <DIR> .
    10/04/2010 03:34 PM <DIR> ..
    10/04/2010 01:25 PM 14,817,259 ct.sym
    10/04/2010 01:25 PM 145,442 dt.jar
    10/04/2010 01:25 PM 218,066 htmlconverter.jar
    10/04/2010 01:25 PM 18,396 ir.idl
    10/04/2010 01:25 PM 1,692 jawt.lib
    10/04/2010 01:25 PM 388,074 jconsole.jar
    10/04/2010 01:25 PM 296,524 jvm.lib
    10/04/2010 01:25 PM 429 orb.idl
    10/04/2010 01:25 PM 3,326,519 tools.pack
    10/04/2010 01:26 PM <DIR> visualvm
    10 File(s) 19,212,401 bytes
    3 Dir(s) 37,790,547,968 bytes free

  17. #17
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Nonono, check the directories jdk\jre\lib and jre\lib in your \Program Files\Java root directory; the lib directory just under the jdk directory has nothing to with it.

    kind regards,

    Jos

    edit: hold on for a second: you have a 64 bit processor; did you install the 64 bit Windows version of it all?
    Last edited by JosAH; 10-04-2010 at 09:19 PM.

  18. #18
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    OK - I'm pretty sure I'm running 32-bit Windows although yes I do have an AMD-64 processor.
    Here is the relevant directory: (no rt.jar just alt-rt.jar)

    Volume in drive C is PC_AMD64
    Volume Serial Number is B4B3-B575

    Directory of C:\Program Files\Java\jdk1.6.0_21\jre\lib

    10/04/2010 04:23 PM <DIR> .
    10/04/2010 04:23 PM <DIR> ..
    10/04/2010 01:25 PM 68,071 alt-rt.jar
    10/04/2010 01:25 PM <DIR> applet
    10/04/2010 01:25 PM <DIR> audio
    10/04/2010 01:25 PM 1,230 calendars.properties
    10/04/2010 01:25 PM 82,115 classlist
    10/04/2010 01:25 PM <DIR> cmm
    10/04/2010 01:25 PM 5,506 content-types.properties
    10/04/2010 01:25 PM <DIR> deploy
    10/04/2010 01:26 PM <DIR> ext
    10/04/2010 01:25 PM 3,828 flavormap.properties
    10/04/2010 01:25 PM 2,710 fontconfig.98.bfc
    10/04/2010 01:25 PM 7,603 fontconfig.98.properties.src
    10/04/2010 01:25 PM 3,478 fontconfig.bfc
    10/04/2010 01:25 PM 9,768 fontconfig.properties.src
    10/04/2010 01:25 PM <DIR> fonts
    10/04/2010 01:25 PM <DIR> i386
    10/04/2010 01:25 PM <DIR> im
    10/04/2010 01:25 PM <DIR> images
    10/04/2010 01:25 PM 88,256 jce.jar
    10/04/2010 01:25 PM 2,807 jvm.hprof.txt
    10/04/2010 01:25 PM 40,960 launcher.exe
    10/04/2010 01:25 PM 2,245 logging.properties
    10/04/2010 01:25 PM <DIR> management
    10/04/2010 01:25 PM 382 management-agent.jar
    10/04/2010 01:25 PM 2,307 meta-index
    10/04/2010 01:25 PM 3,070 net.properties
    10/04/2010 04:23 PM 0 new.txt
    10/04/2010 01:25 PM 3,070 psfont.properties.ja
    10/04/2010 01:25 PM 10,669 psfontj2d.properties
    10/04/2010 01:25 PM 1,133,690 resources.jar
    10/04/2010 01:25 PM <DIR> security
    10/04/2010 01:25 PM <DIR> servicetag
    10/04/2010 01:25 PM 1,210 sound.properties
    10/04/2010 01:25 PM 7,936 tzmappings
    10/04/2010 01:25 PM <DIR> zi
    22 File(s) 1,480,911 bytes
    15 Dir(s) 37,833,551,872 bytes free

  19. #19
    javaNeophyte is offline Member
    Join Date
    Oct 2010
    Location
    Montreal
    Posts
    17
    Rep Power
    0

    Default

    I checked my system properties with winmsd - it's a 32-bit version of Windows. The processor is x86 Family...

  20. #20
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,560
    Blog Entries
    7
    Rep Power
    21

    Default

    Quote Originally Posted by javaNeophyte View Post
    OK - I'm pretty sure I'm running 32-bit Windows although yes I do have an AMD-64 processor.
    Here is the relevant directory: (no rt.jar just alt-rt.jar)
    That causes the trouble: you don't have a file with all the core classes (e.g. Object); I don't know what caused the file rt.jar not to be installed because you need it. My guess is that some installer is trying to be smart and goofs completely.

    There are a couple of things you can try:

    1) copy the rt.jar from your jdk/jre/lib directory to your jre/lib directory.
    2) install a 64 bit version of Java.

    Option 1 is a real hack but it may work ...

    kind regards,

    Jos
    Last edited by JosAH; 10-05-2010 at 08:17 AM.

Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 5
    Last Post: 06-02-2010, 01:05 PM
  2. Replies: 3
    Last Post: 06-01-2010, 03:01 PM
  3. java.lang.NoClassDefFoundError
    By bizmut in forum Eclipse
    Replies: 3
    Last Post: 06-15-2008, 12:54 AM
  4. java.lang.NoClassDefFoundError
    By J_a_y in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 11:51 AM
  5. java.lang.NoClassDefFoundError
    By fred in forum Advanced Java
    Replies: 3
    Last Post: 08-01-2007, 05:00 PM

Tags for this Thread

Posting Permissions

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