Java could not find or load the main class

Source: Internet
Author: User

This error occurs when executing commands with Java

localhost:SocketDemo wangwei$ javac Server.java localhost:SocketDemo wangwei$ java Server 6066错误: 找不到或无法加载主类 Server

if the JDK environment variable is configured correctly, the Java Javac java-version command can be identified.

cause of the error :
Using the Java command to run the class file directly, the file has a guide code line error. (using Java commands to run files directly in Ecplise is prone to such errors)

package SocketDemo;

Workaround :
Method 1: Remove the package socketdemo; Execute Javac and Java commands again

Method 2: Keep the package code line, create a Socketdemo directory under this directory, and copy the Server.java in.

localhost:SocketDemo wangwei$ javac SocketDemo/Server.java localhost:SocketDemo wangwei$ java SocketDemo/Server 6066等待远程连接,端口号为6066.....

Successfully solved!

Java could not find or load the main class

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.