1

I have created a sample maven project with Hello World O/P

Hello.Java:-

public static void main(String[] args) {
     System.out.println("Hello World");
}

DockerFile:-

FROM openwhisk/java8action
ADD target/app.jar app.jar
ENTRYPOINT ["java","-jar","app.jar"]

I used

docker build -t myAppDocker
docker run myAppDocker

Its working fine.

Now I am replacing

public static void main

With

public static JsonObject main(JsonObject args)

But now I am getting below error

Error: Main method not found in class com.sample.maven.docker.CustomDocker, please define the main method as:
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application

What are the changes I need to do to work with it

Note: void main is Java's Main-Method , same way JsonObject main is openwhisk's Main-Method, I want to create it using OpenWhisk

Sat
  • 3,520
  • 9
  • 39
  • 66
  • You can have a “void main” and the openwhisk required main. This should make maven and OpenWhisk happy. The former could be and empty method. – user6062970 Mar 13 '20 at 11:13

1 Answers1

1

You are not supposed to create a docker image, but instead to prepare a jar and then deploy it with wsk create action. The actionlooop variant of the java runtime (openwhisk/actionloop-java-v8) also supports deploying a java source. Note that you are expected to get the paramtersa as a Json object and return the result as a Json object using the Google GSon library.