0

I've multiple modules in a project. Later I added multiple spring-boot modules (not dependent on each other) just another projects/services.

The root project builds a jar with no issues. But the other modules in that project doesn't build at all.

error

Error: Could not find or load main class com.app.server.namingserver.NamingServerApplication
Caused by: java.lang.ClassNotFoundException: com.app.server.namingserver.NamingServerApplication

Ive tried all possible solution from this post (How to build jars from IntelliJ properly?)

My IntelliJ version

IntelliJ IDEA 2018.2.1 (Ultimate Edition) Build #IU-182.3911.36, built on August 7, 2018

JRE: 1.8.0_152-release-1248-b8 x86_64 JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

macOS 10.13.6

Any other solution?

vyeluri5
  • 487
  • 5
  • 8
  • 18
  • 1
    this has nothing to do with building a jar, rather with a dependency missing from your repository/classpath -> Caused by: java.lang.ClassNotFoundException: com.app.server.namingserver.NamingServerApplication – Stultuske Aug 22 '18 at 06:39
  • adding manifest file/folder in resources worked for me. in past, i had same issue but now i don't remember how i solved it – dorintufar Aug 22 '18 at 06:40
  • NamingServerApplication is a separate module and it has no dependencies. I also have a manifest at this path /src/main/resources/META-INF/MANIFEST.MF – vyeluri5 Aug 22 '18 at 06:42
  • It turns out $JAVA_HOME is empty. Also, i cannot run the from cmd line by java NamingServerApplication.class I added export JAVA_HOME=$(/usr/libexec/java_home) but it still has the same error. Anyone got a similar type? – vyeluri5 Aug 22 '18 at 07:34
  • Seems you have no understanding of classpaths and dependency trees in Java. – jwenting Aug 22 '18 at 09:09
  • 1
    @vyeluri5 see http://stackoverflow.com/a/42200519/104891 and http://stackoverflow.com/a/42660624/104891. – CrazyCoder Aug 22 '18 at 20:17
  • I was able to make this work by generating Jar (copy to the output dir and link via manifest). I later tried copying the same class-path to single generated Jar with no luck! – vyeluri5 Aug 22 '18 at 23:18

0 Answers0