Cannot start Java application with Maven from Eclipse, but it works on the command line

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

I cloned the code, I created and compiled the code on the command line, and it ran successfully.

But now I have imported the project into eclipse and it will not start. I always get the error:

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

I tried googleing an error, but did not find a simulation situation. Anyone who can help me on the path to a solution because I cannot make heads or tails out of it.

I assume this is not a bug in the code, this is code from Google, and it worked when I compiled on the command line. So it must be something from an eclipse. I made an import of an existing maven project. It gave no errors or anything else, and then I tried to run with the error above as a result.

thanks! (if you need more information, please ask in the comments and I will provide)

UPDATE:

I have installed

Eclipse Juno Version Version: 4.2.1

M2e 1.2 plugin (Maven integration for eclipse)

Apache Maven version 3.0.4.

UPDATE 2:

I also noticed that 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 

More detailed information

+4
source share
4 answers

I imported the application into Netbeans and it worked. I still don't know what went wrong with Eclipse and did not find a solution. While I'm using Netbeans.

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

+3
source

You will need to check the path configuration. Simply importing the source tree into eclipse does not work (eclipse is crap when it comes to understanding maven files). You should try to recreate the classpath / project with maven:

 mvn eclipse:eclipse 

will create .classpath / .project for you

Also keep in mind that the eclipse is limited to only one area of ​​the classpath where maven uses 4 different ones (so your test classes are related to your project)

PS: if you can afford it - get an IDEA license and forget about such problems.

+4
source

If you work with Eclipse, for example, Run configuration , check the botton view (create Maven in the tree) that you use maven in your assembly: it can be built-in or external . If there is a built-in , replace it with an external one if you have already added it to eclipse.

If you have not added external maven to eclipse yet, follow these steps:

Window β†’ Settings β†’ Maven β†’ Preferences β†’ Add

And add the path to the external maven. Then try again :) I hope this helps you.

0
source

Try removing the default virtual machine arguments that are preconfigured using the project.

Assuming you are running Eclipse on Windows, you can remove the arguments by following the link:

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

Then go to the β€œArguments” tab and delete the arguments of the virtual machine.

Click "Apply", then "Run", and you should see that the program is running (provided that you have completed ALL steps <http://samples.google-api-java-client.googlecode.com/hg/calendar -cmdline-sample / instructions.html).

0
source

Source: https://habr.com/ru/post/1447960/


All Articles