Recently look again java, But by a seemingly very basic hellorworld Headache for more than ten minutes , Baidu for a while , If you are cmd Edit and run .java Wrong times for documents , The solution is as follows , As shown in the figure :

d Under the packing directory .java file .

open cmd, Get into d Packing directory for javac demo.java, As shown in the figure :

There is no mistake in this step , Because as long as your classpath Set up the success , There will be no error reporting ,

At this point we see what we just compiled demo.class It's already in the root directory .

When you go on to the next step , We will find that cmd Report errors , As shown in the figure :

I believe many new students have encountered this problem , Baidu search takes time and effort , Sometimes the solutions written by many people will not solve the problem at all .

Let's just load the dry goods , There are such problems , Tend to be classpath Incomplete configuration .

As shown in the figure :

In the environment variable classpath in , The variable value is preceded by .; Confirm and rerun cmd Problem solvable , As shown in the figure :

As for how to configure environment variables , Please look at the one in front of me java Perfect configuration strategy .

cmd Run under java When you file , Unable to find or load more articles about the main class's solution

  1. stay CMD Next use java The command appears “ Cannot find or load main class ” problem

    Solutions : Find out the reasons and solutions from the Internet , There are references to environment variables classpath Problems setting up the , But after many attempts, the problem remains unsolved . And then use java -cp %classpath; Hello perform , Results the correct . Use echo  ...

  2. kafka Running error : Prompt the main class cannot be found or cannot be loaded. Error resolution

    kafaka edition :kafka_2.11-1.1.0 There are reasons 2 individual :1   The directory cannot have spaces   D:\Soft\kafka_2.11-1.1.0 , Put it in Program Files There's been a problem in the catalog 2   modify D ...

  3. Java Of cmd To configure ( That is to say Java Of JDK Configuration and related common commands )—— Cannot find or load main class Solutions for

    Java Of cmd To configure ( That is to say Java Of JDK Configuration and related common commands ) —— Cannot find or load main class   Solutions for It's been a time of obsession with cmd Next Java Can't compile run problems . The main problems are described as follows : javac Orders can be positive ...

  4. mac Next Use java function class file Always prompt “ error : Cannot find or load main class ” Solutions for

    Find the problem Switch to mac Behind the platform , Suddenly I want to write some programs to run in mac Next , The thought of mac Bring their own java, It will be much more convenient . But in the process, I had trouble : Always prompt “ error : Cannot find or load main class ” Engineering structure It's been a long time , Finally found the prototype ...

  5. javac Compile successfully , use java function class The file appears “ Cannot find or load main class ” The problem of

    1.pack Package name after , The package corresponds to the system folder one by one . And the package name in the code does not contain the name of the package , That is, the file name 2.javac according to *.java File path to compile , After compilation , Use java + Full package name ( Contains the package name ...

  6. function .class File prompt cannot find or load main class reason

    stay Java At the beginning of learning , Write a... In a text file “hello world” The simple procedure of . stay dos Using commands in the environment javac -test1.java Compile . Compiler is known as test1.class Of Java Run the file . ...

  7. Run... From the command line java appear " error : Cannot find or load main class " terms of settlement

    First, you don't need to write to run on the command line package route , And in the ide In general, there is a path so Illustrate with examples For example, the program name is HelloWorldTest.java, The program contains package helloWorld sentence , And the package ...

  8. function Java cmd Program Can't find or load the main class

    // There are several reasons for this problem , But it doesn't have much to do with environmental variables // Be able to execute java  and  javac  It proves that your environment variables have been configured , Actually  classpath  You can not configure // If there are the following documents :H:\cod ...

  9. Java error : Cannot find or load main class ( The source file contains the package name package)

    1. Problem location compile (javac) And execution (java)java The program , This type of error : Cannot find or load main class : First of all, the problem caused by improper configuration of environment variables is excluded , Just promise , The command line interface recognizes javac/j ...

Random recommendation

  1. mkdir Create directory

    mkdir:make directories( Create directory ) The first requirement for creating a directory : In the current directory or the directory you want to create , The user has write permission ,mkdir The detailed functions are as follows : 1.mkdir Without any parameters , namely mkdir di ...

  2. Android Get the contact of the system

    This paper mainly introduces android How to get the contact data of the system in First turn on the simulator Click the contact icon button The system contact database is empty , open File explorer, find data/data The folder below : take conta ...

  3. 【C Language introduction tutorial 】4.5 Definition and reference of pointer variable

    A pointer variable is a variable that contains a memory address . A general variable directly contains a specific value , The pointer variable contains the memory address of a specific data type . Ordinary variables refer directly to the values , Pointer variables refer indirectly to the value in the memory address they point to . Pointer variables need to be declared and ...

  4. Python Network resources + Python Manual

    How to learn Python + How to use Python Related network resources + How to use it Python Bring your own manual (Python Manual) I almost forgot to say , Before looking at all of the following , about python The version doesn't understand , ...

  5. centos System view system version 、 Kernel version 、 System digits 、cpu Number 、 The core number 、 Number of threads

    centos Check the system version cat /etc/redhat-release CentOS Linux release 7.2.1511 (Core) 1) see centos Version of the kernel : [[email protected] ...

  6. 【 translate 】 Write support SSR General component guide for

    From the original :https://blog.lichter.io/posts/the-guide-to-write-universal-ssr-ready-vue-compon?utm_campaign=Vu ...

  7. Two classic e-commerce CSS Layout

    Holy Grail layout and double wings layout ! The two layouts have the same function , It's all about fixing the width at both ends , Middle width adaptive three column layout The holy grail layout : All three areas are left floating , And make main The width of the parent container 100% Add negative values to both sidebars margin ...

  8. Print the ticket , It uses BarcodeLib

    Print private void Control_Click(object s,EventArgs e) { if (((Control)s).Name == "button1") ...

  9. n The number of rabbits a month later (for loop )

  10. adjustment Windows XP Input method order

    Execute Regedit.exe to HKEY_CURRENT_USER\Keyboard Layout\Preload Adjust input method order , The name in the right column is 1 The key value of is the internal input method , Its value is generally 00000 ...