java - Could not find main class:program will exist (Exception in main() thread NoClassDefFoundError) -


import java.security.*; import java.math.*;  public class md5 {     public static void main(string args[]) throws exception{         string s="anand";         messagedigest m=messagedigest.getinstance("md5");         m.update(s.getbytes(),0,s.length());         system.out.println("md5: "+new biginteger(1,m.digest()).tostring(16));     } } 

in code fine plus working before wen i'm running above code mentioned exception occurs... adding installed jdk few seconds ago.. done path java_home.. still exception.. help...!!!!!

java_home=c:\program files\java\jdk1.6.0_45\ java installed..

path=c:\program files\java\jdk1.6.0_45\bin;

classpath=%catalina_home%\lib\servlet-api.jar;c:\program files\java\jdk1.6.0_45\bin;

compiling command:

javac md5.java 

running command:

java md5 

you need tell java can find classes (or rather, roots of package trees). sinc eyour class in default package, , located in directory run java command, need

java -classpath . md5 

or

java -cp . md5 

you should never rely on global classpath environment variable. doing nightmare have 2 different java apps. , jdk bin folder has nothing in classpath.

note using default package bad practice, , should never put own files in directory java installed.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -