简体   繁体   中英

How to reset the system variable: CLASSPATH for JAVA?

I am using Windows 7 and I modified the CLASSPATH and now, in the cmd window, my JAVA cannot work properly: it can compile classes properly, but when I try to run it using: "java CLASS" , the system always says "Could not find or load main class"

The reset 2 system variables related to Java are:

  1. JAVA_HOME: C:\\Program Files\\Java\\jdk1.8.0_31
  2. Path: C:\\Program Files\\Java\\jdk1.8.0_31\\bin

  3. CLASSPATH: .;C:\\Program Files\\Java\\jdk1.8.0_31\\lib (Updated version, still not working...)

Now, how could I reset my CLASSPATH?

My test code:

public class a {
public static void main(String[] args){
    System.out.println("abc");
 }
}

Use Your CLASSPATH

.;c:\Program Files\Java\jdk1.7.0_05\lib

Use ".;" . is refer to this and will find your class.

Your JAVA_HOME

c:\Program Files\Java\jdk1.7.0_05

and Your Path

c:\Program Files\Java\jdk1.7.0_05\bin;

Use this ... this is working fine for me.

You have to set path for your java Follow these steps:

1- Go to My computer

2- Properties

3- Advanced System Settings

4- Environment Variables

5- Select path in the 2nd LOWER LIST BOX

6- click on edit

Now first go to c:program files/java/jdk1.*/bin/ and copy this path at the end of your path

PATH: c://whatever/whatever APPEND: c://whatever/whatever***;//c://program files/java/jdk/bin***

You set your JAVA_HOME incorrectly. The JAVA_HOME home always should be like this -

JAVA_HOME: C:\Program Files\Java\jdk1.8.0_31;  

Note : the JAVA_HOME is set up to just before bin directory.

I think modifying the JAVA_HOME like this would solve your problem. The PATH added here seems OK.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM