0
C:\>set JAVA_HOME=C:\Program Files\Java\jdk1.6.0_02

C:\>set path=./;C:\Program Files\Java\jdk1.6.0_02\bin;%path%

C:\>set classpath=%classpath%;

C:\>javac
Usage: javac <options> <source files>
where possible options include:
  -g                         Generate all debugging info
  -g:none                    Generate no debugging info
  -g:{lines,vars,source}     Generate only some debugging info
  -nowarn                    Generate no warnings
  ... (rest stripped)


C:\>javac sa1.java

C:\>java sa1
Exception in thread "main" java.lang.NoClassDefFoundError: sa1

C:\>

I have installed java in c drive I have set path properly but prg is not running.

Please help me.

0

3 Answers 3

1

Your classpath does not contain the execution-directory C:>set classpath=%classpath%;

try C:>set classpath=.;%classpath%;

Sign up to request clarification or add additional context in comments.

Comments

0
C:>set path=./;C:\Program Files\Java\jdk1.6.0_02\bin;%path%

Think the problem is with the ./ Take away the forward slash

C:>set path=.;C:\Program Files\Java\jdk1.6.0_02\bin;%path%

If your classpath does not have the current directory . Put that in.

Comments

0

It looks like your java source file compiles (with the current classpath settings) but won't execute. Do you need additional jars to execute the application? If not, please delete the CLASSPATH variable. If there is no classpath set through this variable or the -cp parameter, it defaults to the working directory (.) which is OK in most cases.

Double check the package definition of your sa1 class, if it is located in the correct directory and if you're in the correct working directory. Just an example:

 package com.example;
 public class Test {}

The compiled class file needs to be stored in ./com/example/Test.class. Then you can execute the application (imagine it has a main method) with java com.example.Test

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.