At the moment I'm running the demo StockWatcher in Eclipse. This uses the embedded servlet container which is fine for my purposes. The only change I would like to make is running from the command line instead of inside Eclipse. Does anyone know what command I use and what classpath this requires?
Edit - I have not used maven I have created the project purely using eclipse and gwt plugin
If you used the webAppCreator wizard (I see that you used the Eclipse plugin, but maybe both of them used the same code internally), you should have an ant script (build.xml) generated for you. With it you can run the GWT app via targets so:
ant hosted - run hosted mode (or Development mode, I'm looking at a fairly old ant script)
ant gwtc - compile to JS
ant war, ant build, etc.
See what's in that file (build.xml) to get a better understanding of what is available and what you can do.
Update: see here for documentation on webAppCreator and available ant targets.
With the maven jetty plugin you can run your application with jetty from command line. (You first have to compile & create war with maven gwt plugin I think)
mvn jetty:run
maven gwt plugin
maven jetty plugin
Did you use Maven for this project? If that, then you can run it as mvn gwt:run from command line
Related
I try to build a project, which is using the Maven Wrapper. The build works fine on command line. There is also a plug-in for IntelliJ Idea. However, I haven't found any article, how to build such project with Eclipse.
Do you have an experience with project build by ./mvnw command instead of mvn in Eclipse, please?
As implied by the comment from LMC, the Java edition of Eclipse will come with the "m2e" plugin, which will automatically recognize a project with a pom.xml file as a Maven project, and it will automatically note the dependencies, download them, and compile your source code with those artifacts as dependencies.
That deals with dependencies and compilation. If your build is running unit tests with Surefire, or generating code with particular plugins, unless there is a specialized m2e connector for that plugin, Eclipse will not know to do that.
Inside Eclipse, if you need to run a Maven build, you don't need to care about "mvn" vs. "mvnw". Eclipse will have an embedded Maven installation.
I have a simple java main class and can execute it using the below command on server
java com.....MainClass
Now we are trying to use Maven in our application.
I am seeing on web that the maven command to execute java program is
mvn exec:java -Dexec.mainClass=com......MainClass
Can I still use regular java command or do I have to use the maven command exec:java?
It's not clear to me when to use the maven exec:java command.
Please help me understand when to use regular java command and when to use the maven exec:java command.
when I use Maven can I still execute program using regular java command.
Maven
According to https://maven.apache.org/what-is-maven.html Maven's objectives are
Making the build process easy
Providing a uniform build system
Providing quality project information
Providing guidelines for best practices development
Allowing transparent migration to new features
So, you should use Maven for building your project... like building a JAR package with main class.
Running JAR packaged main class
See this answer or this Oracle's tutorial for running a JAR packaged Java class.
You can also use Maven for running the main class but you should not make your production environment depended on Maven.
maven is mainly a dependency mangement and a build tool.
u can still use java command to run your main class from the jar generated by maven under the target folder of your project.
java -cp "yourProject/target/folder-containing-dependenc-jars-if-exist/*:yourProject/target/thejar.jar" package.mainClass
ps: use the ":" separator on linux system , if you are under windows use ";"
I downloaded the glass-java-starter from github and followed all of the instructions on the glass developers site. I got it imported into Eclipse as a Maven existing project as instructed and I changed the oAuth file ID and Secret as specified. When I try to start the project or debug the project I am getting the following exception: Source not found for http://cwiki.apache.org/confluence/display/MAVEN/NoGoalSpecifiedException. The instructions give a command line command for running the project, $ mvn jetty, but nothing for Eclipse. How do I debug this project with Eclipse?
You will need to use one of the maven plugins available for Eclipse to initiate the run:jetty goal.
There are a few available. One of them is Eclipse m2e.
Install the plugin
Create a new run configuration of type Maven Build
Specify a goal of jetty:run
Other solution would be:
set jetty debug port:
export MAVEN_OPTS='-Xdebug -Xrunjdwp:transport=dt_socket,address=4000,server=y,suspend=y'
then run jetty through maven command line
mvn jetty:jetty
After that use Eclipse remote debugger on port 4000.
The war file, product that mvn produce in this sample app is compatible with tomcat or any other standalone server, so just build a war to "webapp" directory of standalone tomcat or jetty or "deploy" directory of standalone JBoss.
Eclipse has plenty of plugins to run those in debug mode.
I've got a java project that's using Maven in Eclipse, and would like to completely remove the Maven aspect of the project, and set it up as a completely stand alone Dynamic Web Project that doesn't depend on Maven at all, but uses Ant instead.
I assume this will involve:
finding out the libs that are required
creating an ant "build.xml" file
more steps that I'm not sure of ;-)
What's the best way to do this?
You could switch it to use ant. Maven comes with ant plugin. Run mvn ant:ant and it will generate the build.xml for you. This would make you dependent on ant though.
Probably the easiest thing to do is install m2e and m2e-wtp in Eclipse.
Then make sure your Maven project is packaged as a .war. See here for building a web app in Maven:
http://www.mkyong.com/maven/how-to-create-a-web-application-project-with-maven/
Eclipse will see it as a Dynamic Web App with all the configuration and deployment capabilities.
We have a project that uses Maven as its build/dependency management tool. But our code needs to be compiled at our client's site and our client demands that we deliver build scripts written for Ant.
So, we would like to keep working with Maven and automatically generate the Ant scripts when we need to deliver the code to the client.
Can we do that?
You can use the Maven Ant Plugin.