JDK Installation problems!

Praful

Disciple
hey techies...
i've got this really werid problem with the jdk installation. After i write a program in java and then compile it using "javac" then run using the "java <Classname>" command i get this error-
'Exception in thread "main" java.lang.NoClassDefFoundError: <Classname>'
now the that i've written in 100% error free, i ran it on another machine and got the required output, got it checked by XTerminator/XTO_bhai he also said the code is fine and got the required output. So you see there's no problem in the code like the classname and filename mismatch. Now if it was a path setting problem commands like "javac"/"edit" won't work.so its not even a path setting problem. I have also changed from jdk1.4 to 1.5 and back but still same problem. Please give me some gyan on how to get over this problem i really need to code in java on THIS machine....:huh:
So please help ASAP people...
thanks
praful
 
Hi Praful..it would be helpfull if u can actually copy/paste the errors along with ur sample code.

As u said..ur code may be perfect but this error usually occurs because of two reasons:

1)using a wrong class name during exec.

2)Errors in the environment path variables.

edit: i know it sounds silly but u do know that java is case-sensitive..right?..am only saying this cos i kicked myself loads of times for not using appropriate cases :)
 
Well..that wudnt actually solve the problem now..would it EM?..its most probably a classname issue..or a path variable one.

but yeah..Eclipse IDE is the BEST out there!! :)
 
not necessarily. even i had the same problem lot of times . so this is the esy way out... and also eclipse is really awesome to program in java..ya i do know its a path variable mistake
 
ok here's the files for your pleasure...
Try.java
Code:
public class Try
        {
        public static void main(String args[])
                {
                System.out.print("Hey b***h");
                }
        }
another one
First.java
--------
Code:
public class First
{
public static void main(String args[])
{
System.out.println("hello world");
}
}
ok now for Autoexec.bat
--------------
path=C:\j2sdk1.4.2_08\bin\;c:\windows\system32\;
i've even tried using "set path"....
nothing's workin ppl.......
 
ok this is wat exactly happens
 

Attachments

  • untitled.JPG
    untitled.JPG
    103.1 KB · Views: 158
Code:
set path=c:\j2sdk1.4.2\bin;c:\j2sdk1.4.2\lib;.;

then type
Code:
path
to see if it is reflected.

Otherwise, i think its possible that your installer is corrupt and missing some files. Or there is possibly some other installed program on ur HDD which is causing conflicts.
 
well there is nothing wrong in importing the lang package i suppose ;)

why cant you guys just use eclipse saves a helluva lot of time setting the path and stuff
 
also try including the path to the directory in which your file is to the classpath variable. you can find it in the environment variables window
 
I am not a coder - but it should be String[] args instead of String args[] i am not sure about this.

This from sun's site

Code:
/**

 * The HelloWorldApp class implements an application that

 * simply displays "Hello World!" to the standard output.

 */

class HelloWorldApp {

    public static void main([COLOR="Red"]String[] args[/COLOR]) {

        //Display "Hello World!"

        System.out.println("Hello World!");

    }

}
 
dear praful

actually the class path is not given correctly.

type the following at command prompt

C:\set classpath=%classpath%;.;

i hope now you can run the program, best of luck
 
Back
Top