Issue
Hello.java
:
public class Hello {
public static void main(String[] args) {
System.out.println("hello java");
}
}
CMakeLists.txt
:
cmake_minimum_required(VERSION 3.10)
project(Hello)
find_package(Java REQUIRED)
include(UseJava)
set(CMAKE_JAVA_COMPILE_FLAGS "-source" "11" "-target" "11")
set(CMAKE_JAVA_EXECUTABLE Hello)
add_jar(${PROJECT_NAME} Hello.java)
The generated Hello.jar
's MANIFESET.MF, don't have the Main-Class
option.
Even though I've already add:
set(CMAKE_JAVA_EXECUTABLE Hello)
Any idea how I can make the jar file executable?
I prefer not to write a MANIFEST.MF myself, or edit the one in generated .jar
.
Solution
You need to add ENTRY_POIN that points to the main class into the add_jar as:
add_jar(${PROJECT_NAME} Hello.java ENTRY_POINT Hello)
Answered By - kofemann