Giter Site home page Giter Site logo

Comments (8)

johanandren avatar johanandren commented on May 25, 2024

If you must stay on JDK 8 the last version of Akka supporting it is 2.8.5, you could try building the quickstart with that.

from akka.

shaoshuaidu avatar shaoshuaidu commented on May 25, 2024

If you must stay on JDK 8 the last version of Akka supporting it is 2.8.5, you could try building the quickstart with that.

Hi Johanadren, thank you for your reply. Actually I am using Akka 2.8.5. Here is my pom file. Is there anyproblem with it?

4.0.0
<groupId>hello-akka-java</groupId>
<artifactId>app</artifactId>
<version>1.0</version>

<properties>
  <akka.version>2.8.5</akka.version>
</properties>

<repositories>
    <repository>
        <id>akka-repository</id>
        <name>Akka library repository</name>
        <url>https://repo.akka.io/maven</url>
    </repository>
</repositories>

<dependencies>
    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor-typed_2.13</artifactId>
        <version>${akka.version}</version>
    </dependency>
    <dependency>
        <groupId>ch.qos.logback</groupId>
        <artifactId>logback-classic</artifactId>
        <version>1.2.13</version>
    </dependency>
    <dependency>
        <groupId>com.typesafe.akka</groupId>
        <artifactId>akka-actor-testkit-typed_2.13</artifactId>
        <version>${akka.version}</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>4.13.2</version>
        <scope>test</scope>
    </dependency>
</dependencies>
<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source>    
                <target>1.8</target>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>exec-maven-plugin</artifactId>
            <version>3.0.0</version>
            <configuration>
                <executable>java</executable>
                <arguments>
                    <argument>-classpath</argument>
                    <classpath />
                    <argument>$package$.AkkaQuickstart</argument>
                </arguments>
            </configuration>
        </plugin>
    </plugins>
</build>

from akka.

shaoshuaidu avatar shaoshuaidu commented on May 25, 2024

If you must stay on JDK 8 the last version of Akka supporting it is 2.8.5, you could try building the quickstart with that.

And my java version is 1.8 and maven version is 3.8.3. Should the version of maven be same as the version of maven compiler plugin?

from akka.

johanandren avatar johanandren commented on May 25, 2024

Ah, I see now what is wrong, you have probably cloned the entire java quickstart repository, but that is structured for project creation through the sbt (the build tool most common for Scala) templating functionality, not to be cloned and run directly.

Generally such project creation is done via sbt new akka/akka-quickstart-scala.g8, which will give you some prompts to specify project name, package name, Akka version etc.

If you do not want to install sbt to do that you can instead download a zip file of the project template from this page: https://developer.lightbend.com/guides/akka-quickstart-java/ and it should work as expected.

from akka.

shaoshuaidu avatar shaoshuaidu commented on May 25, 2024

Ah, I see now what is wrong, you have probably cloned the entire java quickstart repository, but that is structured for project creation through the sbt (the build tool most common for Scala) templating functionality, not to be cloned and run directly.

Generally such project creation is done via sbt new akka/akka-quickstart-scala.g8, which will give you some prompts to specify project name, package name, Akka version etc.

If you do not want to install sbt to do that you can instead download a zip file of the project template from this page: https://developer.lightbend.com/guides/akka-quickstart-java/ and it should work as expected.

Hi Johanandren,

Thank you for the information. Scala is an interesting and new language for me. But it seems not to be the reason of problem.

I finally found the bug is cuased by java version incompatibility. The code below (which is a record class, only supported by java 14 version and afterwards), is not supported by java 8.

public static record Greet(String whom, ActorRef<Greeted> replyTo) {}
 public static record Greeted(String whom, ActorRef<Greet> from) {}

So I change these code into typical class, and it works. Cheers!

public static final class Greet{
    private final String whom;
    private final ActorRef<Greeted> replyTo;

    public Greet(String whom, ActorRef<Greeted> replyTo){
      this.whom = whom;
      this.replyTo = replyTo;
    }

    public String whom(){
      return this.whom;
    }

    public ActorRef<Greeted> replyTo(){
      return this.replyTo;
    }

    public String toString(){
      return String.format("Point[x=%s, y=%s]", this.whom, this.replyTo);
    }

    public boolean equals(Object o){
      return true;
    }

    public int hashCode(){
      return 110;
    }
}
 public static final class Greeted{
    private final String whom;
    private final ActorRef<Greet> from;

    public Greeted(String whom, ActorRef<Greet> from){
      this.whom = whom;
      this.from = from;
    }

    public String whom(){
      return this.whom;
    }

    public ActorRef<Greet> from(){
      return this.from;
    }

    public String toString(){
      return String.format("Point[x=%s, y=%s]", this.whom, this.from);
    }

    public boolean equals(Object o){
      return false;
    }

    public int hashCode(){
      return 120;
    }
  }

from akka.

johanandren avatar johanandren commented on May 25, 2024

Ah, sorry, didn't remember that, yes, we switched to showcasing newer JDK features a while ago, if you start from commit akka/akka-quickstart-java.g8@269d369 I think that should still work with JDK 8 (alternatively rewrite those records to regular Java classes like you did)

from akka.

shaoshuaidu avatar shaoshuaidu commented on May 25, 2024

Ah, sorry, didn't remember that, yes, we switched to showcasing newer JDK features a while ago, if you start from commit akka/akka-quickstart-java.g8@269d369 I think that should still work with JDK 8 (alternatively rewrite those records to regular Java classes like you did)

Yeah, thanks. And I also create a new repo for java8 version, for new beginners like me. Here is the link https://github.com/shaoshuaidu/akka-quickstart-java8.

from akka.

johanandren avatar johanandren commented on May 25, 2024

Thanks for sharing, I'll close this issue now.

from akka.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.