Maven 1.0 snapshot .jar cannot find class name - eclipse

I wrote maven project and it run correctly in Eclipse but I want to run maven project in cmd line so I write this line in cmd
java -cp target/my-app-1.0-SNAPSHOT.jar com.my.App
I have this error
Could not find or load main class com.my.App
How I solved it?

Related

How to build maven spark project (Scala), then import and config eclipse

I have cloned this project: https://github.com/sryza/aas
and built successful with maven ( pom.xml)
I then import to Eclipse oxygen ( scala IDE plug in), open and run the file "main.scala", and had an error: not found the main class though I had tried to run as configuration with scala nature. Which step i missed?
In general how can i config eclipse to switch with Java, Scala, and python(install PyDev)
Thanks for your help
You can try the following:
1 When you clone the project use: mvn eclipse:eclipse so you can import it in eclipse.
2 Run mvn clean install to see if the project is building
Witch Eclipse IDE for Java EE Developers you should be able to run it

Intellij class path setting when build a jar for maven project

when running the jar in command line, throw this exception:
java.lang.ClassNotFoundException
When building jar in intellij, we need set the manifest properties, like main class, class path, where could I find the right setting for this? it is not in the manifest file

How to create a groovy jar with eclipse/ggts?

So I create a groovy jar but I'm not able to run it.
I'm using HelloWorld.groovy as an example
class HelloWorld {
static main(args) {
println("Hello World");
}
}
I save it as a jar like I would with any java file via export in eclipse/ggts:
right clicking groovy file in project explorer
click export
select jar File
specify jar file name
specify HelloWorld as the main class in the Manisfest file
keep all the defaults selected
click finish and create the jar
Now I try to run HelloWorld.groovy via java -jar HelloWorld.jar on my command line.
I get:
Exception in thread "main" java.lang.NoClassDefFoundError: groovy/lang/GroovyObject
When I export it also allows me to export .classpath into my jar.
Shouldn't that include my groovy-all.jar that my GGTS is using?
Am I missing something?
I've been successful with using GroovyWrapper to create groovy jars. I want to see if it's possible with just my IDE.
I think that in eclipse you export an executable jar and that gives the option to package the dependencies?

Run junit4 test from cmd

I tried to run junit4 test case from command line using:
java -cp junit-4.8.1.jar;test\Dijkstra;test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
but I got the following error:
java.lang.NoClassDefFoundError: graph/shortestgraphpath;
while the test case is working without any problems in eclipse.
Hint: in eclipse, shortestgraphpath was added in Referenced Libraries.
You need to the jar file containing shortestgraphpath to java class path.
java -cp junit-4.8.1.jar;test\Dijkstra; test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
The class path is the value that you pass to java with -cp so in your question you just supply junitand your compiled classes.
Try updating it with the jar file with the missing class.
java -cp junit-4.8.1.jar;<path to jar file>;test\Dijkstra;test\Dijkstra\bin org.junit.runner.JUnitCore Data0PathTest00
You might have to add additional jar files as well. I recommend that you take a look at some build tool to help you build and run your java applications for example Maven, Gradle, Buildr.

Setting up Akka with Eclipse

I am trying to get a simple Akka program building with Eclipse and Scala. I used g8 to create the sbt project with Akka(g8 typesafehub/akka-scala-sbt) and then sbteclispe to create the Eclipse project. When I import the project into Eclipse I'm given errors saying I am missing Akka. Is there any way that I can build an Akka project with Eclipse?
The simplest thing is to add the sbteclipse plugin to your Sbt build. It automatically generates project files for Eclipse, so that you can import your project with all its settings, classpath included. To do so, add the following under project/plugins.sbt (not in the root of your project, but under the project subdirectory):
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
then, start sbt and at the prompt write eclipse. You should see:
> eclipse
[info] About to create Eclipse project files for your project(s).
[info] Successfully created Eclipse project files for project(s):
[info] Test Project
Then go to Eclipse and Import your project.
I use this to start the 1.x microkernel from the IDE, I think it came from Henke:
Main class : akka.kernel.Main
VM args:
-Xms256m -Xmx1024m -Dakka.home=./kernel -Dlogback.configurationFile=src/main/resources/logback.xml
In kernel directory I have a symlink config -> ../src/main/resources
In the kernel directory I also have an empty deploy directory. Not used, but must be there.