简体   繁体   中英

java JDK 1.8.0 Win 11 - system variables

I've just istalled JDK8 on PC Windows 11 Home Now im trying to run simple default program from NetBeans14

In environmental variables:

PATH : C:\Program Files\Java\jdk1.8.0_202\bin

CLASSPATH : C:\Program Files\Java\jdk1.8.0_202\bin

Project build on hard disk C:\Projects\Hello\src\main\java\pack\hello

  1. on cmd going tn cd C:\Projects\Hello\src\main\java\pack\hello

  2. javac compiles .java file on .class file

  3. command "java Hello" output: Error: Could not find or load main class Hello Hello.class is there.

checking commands, all works:

java

javac

javac -version

Please to support, or send some similar problems posts. All web answers are speaking about setting PATH and CLASSPATH, where in my case it already took place.

Thanks in Advance

I tried to follow your steps. I downloaded and installed the newest JDK 8 on Windows 11, and NetBeans 14.

Then I looked through the Environment Variables, and the only mention of Java was in the system Path variable:

在此处输入图像描述

You see, I have no CLASSPATH variable, nor haven't I manually set anything. Everything was installed automatically. I have no explicit path to C:\Program Files\Java\jdk1.8.0_... in my Path variable.

And I created a simple app in NetBeans. It runs from NetBeans successfully. Just do "Run Project" (F6) in the NetBeans interface.

If you need to run it from the command line for some reason, this question may help.

If you need to run it on another computer, I would advise you not to do it with cmd. Compile it into jar, then wrap it into exe (in case of Windows) using launch4J.

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