I’m newbe in Java world, but I know some concepts and want to practice in Java.
My environment:
> echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home
> java --version
java 17.0.10 2024-01-16 LTS
Java(TM) SE Runtime Environment (build 17.0.10+11-LTS-240)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.10+11-LTS-240, mixed mode, sharing)
ls -la /Library/Java/JavaVirtualMachines
total 0
drwxr-xr-x 5 root wheel 160 Apr 29 10:57 .
drwxr-xr-x 4 root wheel 128 Mar 1 14:12 ..
drwxr-xr-x 3 root wheel 96 Apr 29 10:57 jdk-17.jdk
drwxr-xr-x 3 root wheel 96 Mar 1 14:12 jdk-21.jdk
lrwxr-xr-x 1 root wheel 45 Mar 1 18:03 openjdk-11.jdk -> /usr/local/opt/openjdk@11/libexec/openjdk.jdk
Steps I did:
I built a project based on flink guidance using maven:
-DarchetypeGroupId=org.apache.flink
-DarchetypeArtifactId=flink-walkthrough-datastream-java
-DarchetypeVersion=1.18.1
-DgroupId=com.test.project
-DartifactId=test-project
-Dversion=0.1
-Dpackage=com.test.project
-DinteractiveMode=false
When I opened this project in VSCode and tried to run the class, I see the following error:
Error: Main method not found in the file, please define the main method as: public static void main(String[] args)
I tried to setup .vscode/settings.json
with following values:
{
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home",
"default": true
}
]
}
VSCode user settings look like:
"maven.executable.path": "/Users/vladislav/dependencies/apache-maven-3.9.6/bin/mvn",
"java.configuration.runtimes": [
{
"name": "JavaSE-17",
"path": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home",
"default": true
},
],
"java.jdt.ls.java.home": "/Library/Java/JavaVirtualMachines/jdk-17.jdk/Contents/Home",
The project contains the file FraudDetectionJob.java
with the main
function:
package com.test.project;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.walkthrough.common.sink.AlertSink;
import org.apache.flink.walkthrough.common.entity.Alert;
import org.apache.flink.walkthrough.common.entity.Transaction;
import org.apache.flink.walkthrough.common.source.TransactionSource;
/**
* Skeleton code for the datastream walkthrough
*/
public class FraudDetectionJob {
public static void main(String[] args) throws Exception {
...
}
}
Also I tried to create the project not via Maven CLI, but via Maven extension -> result is the same.
Vladislav Bakanov is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.