IntelliJ IDEA에서 gradle를 이용해 만든 자바 프로그램을 도스 콘솔창에서 실행할 때 "Could not find or load main class 클래스이름"에러 발생한다.
개발환경
- Windows 10 Pro 64-bit English
- IntelliJ IDEA COMMUNITY 2017.2
증상
IntellJ IDEA IDE에서는 정상적으로 실행됨
installDist태스트로 만든 실행파일을 도스창에서 실행하면 "Could not find or load main class 클래스이름"에러 발생
원인
build.gradle파일의 mainClassName항목에 패키지 이름을 포함한 클래스 이름을 써주지 않아서 발생한다.
(main 메쏘드가 있는 클래스 이름만 써주면 에러 발생)
예)
ExampleClass.java
package example.sphinx4;
:
public class ExampleMain {
:
}
Could not find or load main class ExampleMain 에러가 발생하는 build.gradle파일
apply plugin : 'java'
:
mainClassName = 'ExampleClass'
정상적으로 실행되는 build.gradle파일
apply plugin : 'java'
:
mainClassName = 'example.sphinx4.ExampleClass'
'programming' 카테고리의 다른 글
GPIO - 버튼처리 (0) | 2020.08.08 |
---|---|
C언어 - 구조체 멤버 얼라인먼트 (0) | 2019.09.10 |
Visual Studio 안드로이드 에뮬레이터 - Unable to determine the host ip address에러 (0) | 2017.05.18 |
winsock2.h에 있는 qos.h파일을 못 찾는 에러 (0) | 2017.05.06 |
SEGGER J-Link설치 (0) | 2017.04.09 |