2
votes

At the moment I'm trying to run my first flink application. I already tested the java file (KMeans.java) in the IDE and it works perfectly but I can't handle to get this java file run as an jar in command line.
The build was successfully created with mvn clean package. But if I run my jar file in command line flink run -c KMeans name.jar
this error message appears:

The program finished with the following exception:

org.apache.flink.client.program.ProgramInvocationException: The program's entry point class 'KMeans' was not found in the jar file. at org.apache.flink.client.program.PackagedProgram.loadMainClass(PackagedProgram.java:617) at org.apache.flink.client.program.PackagedProgram.(PackagedProgram.java:199) at org.apache.flink.client.cli.CliFrontend.buildProgram(CliFrontend.java:856) at org.apache.flink.client.cli.CliFrontend.run(CliFrontend.java:206) at org.apache.flink.client.cli.CliFrontend.parseParameters(CliFrontend.java:1044) at org.apache.flink.client.cli.CliFrontend.lambda$main$11(CliFrontend.java:1120) at java.security.AccessController.doPrivileged(Native Method) at javax.security.auth.Subject.doAs(Subject.java:422) at org.apache.hadoop.security.UserGroupInformation.doAs(UserGroupInformation.java:1754) at org.apache.flink.runtime.security.HadoopSecurityContext.runSecured(HadoopSecurityContext.java:41) at org.apache.flink.client.cli.CliFrontend.main(CliFrontend.java:1120) Caused by: java.lang.ClassNotFoundException: KMeans at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) at java.lang.Class.forName0(Native Method) at java.lang.Class.forName(Class.java:348) at org.apache.flink.client.program.PackagedProgram.loadMainClass(PackagedProgram.java:614) ... 10 more

So I looked up my generated target folder and there is a KMeans.class file in the classes folder. So I'm doing this wrong?

1

1 Answers

4
votes

You need to specify the full class name, e.g., org.apache.flink.examples.java.clustering.KMeans.

Note that you only need to use the -c flag if the JAR file doesn't specify the class to run in its manifest.