본문 바로가기
프로그래밍

Java 에러 - Could not find or load main class 해결 방법

by 삼굽살 2021. 2. 4.
반응형

"Could not find or load main class ..." 이 오류 메시지와 함께 프로그램이 실행되지 않을 때 

코인 선물 거래소 할인 링크 모음!! 최대 할인률 제공.

BITGET : https://partner.bitget.com/bg/J5ST3D

BINANCE : https://accounts.binance.com/en/register?ref=63834876

MEXC : https://www.mexc.com/register?inviteCode=1LR6x

ASCENDEX : https://ascendex.com/en/register?inviteCode=URHVJV49Z

OKEX : https://www.okex.com/join/12965656

BITMEX : https://www.bitmex.com/register/B5M5EP

ZOOMEX : https://www.zoomex.com/ko-KR/invite?ref=NLM7XN 

 

시스템 변수에서 CLASSPATH의 값을 %JAVA_HOME%; 로 변경해 줍니다.

 

더보기

If you're getting this error and you are using Maven to build your Jars, then there is a good chance that you simply do not have your Java classes in src/main/java/.

In my case I created my project in Eclipse which defaults to src (rather than src/main/java/.

So I ended up with something like mypackage.morepackage.myclass and a directory structure looking like src/mypackage/morepackage/myclass, which inherently has nothing wrong. But when you run mvn clean install it will look for src/main/java/mypackage/morepackage/myclass. It will not find the class but it won't error either. So it will successfully build and you when you run your outputted Jar the result is:

 

댓글