简体   繁体   中英

Scala JAR file; can't find or load main class in a JAR file

I can't figure out why I can't run my JAR files. I have been looking for hours, but I still have no clue.

Originally I need it for my Scala Spark data science thesis project, since I need to run the JAR files on a Spark Cluster, but even a very basic example doesn't work.

What I am trying to do, but that even fails is:

My test code:

object superSimpleTest {
def main(args: Array[String]): Unit = {
  System.out.println("I'm a JAR")
 }
}

I build the JAR file using Intellij as follows:

File -> Project Structure -> Artifacts -> + -> JAR with "from modules with dependencies". From the pop-up window I change the manifest output path to resources. After that I go to Build -> Build Artifact -> Build

创建 JAR 模块 JAR 模块概述

My manifest looks like this:


  • Manifest-Version: 1.0
  • Main-Class: superSimpleTest

When I then run in terminal: java -jar JARNAME.jar I get the error:

Error: Could not find or load main class superSimpleTest

Honestly, at this point, I have no clue what I am doing wrong since the code runs fine within Intellij.

Someone that can help me go forward?

Apparently, it works with

mvn clean compile assembly:single with the Maven Assembly plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM