'Exception in thread "main" java.lang.NoClassDefFoundError: scala/Serializable while using ActorSystem in Java project

I am new to java and AKKA toolkit. I have created a JAVA project and tried to include the below code

    package com.postgresqltutorial;

    import akka.actor.ActorSystem;

    public class App {
        public static void main(String[] args) {
        
        final ActorSystem system = ActorSystem.create("QuickStart");
      }

    }

I have used AKKA libs in referenced libs as akka-actor_2.12-2.6.15.jar, akka-protobuf_2.12-2.6.15.jar and akka-stream_2.12-2.6.15.jar.

And my project structure is like project structure

Please help me to resolve this.



Solution 1:[1]

Most likely you've not referenced the libraries correctly. That is why you should use a build tool such as Maven. Check the referenced link to understand how it works. It handles the libraries for you, you just have to add them in the pom.xml file.

Example:


<dependencies>

    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor_3</artifactId>
        <version>2.6.18</version>
    </dependency>
    
</dependencies>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Renis1235