Stephan Celis
Stephan Celis

Reputation: 2612

Can't run Java Application with Maven from Eclipse but it works in Command line

I'm trying to run a sample from Google. To be precise the Google Calendar cmdline sample (http://samples.google-api-java-client.googlecode.com/hg/calendar-cmdline-sample/instructions.html)

I cloned the code, I've build and comiled the code in command line and it ran succesfully.

But now I imported the project into eclipse and it won't run. I always get the error:

    Error: Could not find or load main class Libs\Google

I tried googleing the error but did not find a simular situation. Anyone that can help me on the way to a solution, because I can't make heads or tails out of it.

I assume it's not a fault in the code, it's code from google and it worked when I compiled in command line. So it must be something from eclipse. I did an import of existing maven project. It didn't gave errors or anything and then I tried to run with the above error as result.

Thx! (if more info is needed please ask in comments and I will provide)

UPDATE:

I have installed

Eclipse Juno version Version: 4.2.1

M2e plugin 1.2 (Maven integration for eclipse)

Apache Maven version 3.0.4.

UPDATE 2:

Also I noticed when I try to open pom.xml in eclipse I get an error.

An error has occurred. See error log for more details.
java.lang.NullPointerException

No further details

Upvotes: 4

Views: 9097

Answers (4)

aseriesofdarkcaves
aseriesofdarkcaves

Reputation: 134

Try removing the default VM arguments that come pre-configured with the project.

Assuming you're running Eclipse in Windows, you can remove the arguments by going to:

Run > Run Configurations... > Java Application > CalendarSample

Then click on the "Arguments" tab and remove the VM arguments.

Hit "Apply", then "Run" and you should see the sample program run (assuming you've followed ALL of the steps @ http://samples.google-api-java-client.googlecode.com/hg/calendar-cmdline-sample/instructions.html).

Upvotes: 0

Stephan Celis
Stephan Celis

Reputation: 2612

I imported the application in Netbeans and it worked. I still don't know what went wrong with Eclipse and didn't find a solution. For now I'm using Netbeans.

If I find a solution I will post it here for future reference.

Upvotes: 3

user1528280
user1528280

Reputation:

If you are running from Eclipse like Run configuration check on the botton view (Maven build in tree) what maven do you use in your build: it can be embedded or external. If there are embedded change it to external, if you are already add it to eclipse.

If you haven't already added to eclipse external maven follow this steps:

Window -> Preferences -> Maven -> Installations -> Add

And add path to your external maven. Then try again :) I hope it will help you.

Upvotes: 0

Konstantin Pribluda
Konstantin Pribluda

Reputation: 12367

You will have to check your classpath configuration. Mere importing your source tree into eclipse does not work ( eclipse is shitty when it comes to understand maven files ). You should try to recreate classpath / project with maven:

mvn eclipse:eclipse

will create .classpath / .project for you

Also keep in mind, that eclipse is constrained to only one classpath scope where maven uses 4 different ( so your test classes wil leakinto your project )

PS: if you can afford - get you license of IDEA and forget about such issues

Upvotes: 4

Related Questions