2
votes

I'm walking through the intro to Dropwizard on a Windows machine, and I seem to be stuck at the point where I'm supposed to be able to run the application. Here's what I execute from the command line:

java -jar target/hello-world-0.0.1-SNAPSHOT.jar

Instead of usage result the intro says I should receive, I get the following error:

Error: Could not find or load main class com.example.helloworld.HelloWorldApplication

The output of the 'mvn package' command indicates a successful build. The configured CLASSPATH environment variable includes '.' for the current directory, as well as the 'lib' and 'bin' subfolder of the JDK installation. JAVA_HOME is correctly configured for the JDK location also. What am I missing in my pom.xml, environment variables or elsewhere that could result in reported successful Maven build where the resulting jar can't be executed?

1
What does the java command look like you're using to execute the jar? - Dan1701
Does com.example.helloworld.HelloWorldApplication actually exist as the main class? One thing about that tutorial, is that the main class is specified in the pom file for one of the plugins. You need to change that to your main class, if it is something different. - Paul Samsotha

1 Answers

2
votes

It's probably either:

  • You forgot to include a package com.example.helloworld; statement at the top of your HelloWorldApplication
  • Your HelloWorldApplication source file is not at the exact path ${project.basedir}/src/main/java/com/example/helloworld/HelloWorldApplication.java (make sure to check the src/main/java part too)