Is there any way to run Vertx from within an IDE? I know I can create a server in a file and then call
vertx run server.java
from the command line, but is there a way to run the server.java file from within an IDE?
Is there any way to run Vertx from within an IDE? I know I can create a server in a file and then call
vertx run server.java
from the command line, but is there a way to run the server.java file from within an IDE?
Vert.x 3
I previously edited an earlier answer, but I'm separating it out for the sakes of clarity.
The example below is for eclipse, but the same basic premise should work with any IDE.
Setup
Set up your Maven, Gradle, or other project and import it into Eclipse
Create a run or debug config, and set
io.vertx.core.Launcher
as your main class.run org.example.InitVerticle -conf <path to config>
; whereorg.example.InitVerticle
is your main, or intialiser, verticle.Debugging
During debugging in Vert.x 3 you may notice that a blocked thread watchdog continually outputs warnings (and, eventually, exceptions) onto the console. Whilst useful during production, you can inhibit this behaviour by setting the following property in VM arguments of your debug config:
CaveatsBe aware that your debugging is liable to trigger timeouts in a variety of scenarios, such as a breakpoint delaying a reply on the eventbus. You'll see warnings like:
Clearly, this could mean different control flows under debugging than real execution if you aren't careful.
The accepted answer is perfectly fine. Just for completness's sake, you also simply can run a plain old java main class, having a the main start your vertx instance.
Code should be something like:
There you go.
My setting below is done at IntelliJ 15.0.1 with vert.x 3.2.0 for Java
add New Verticle like :
'Run' -> 'Edit Configurations...' -> replace 'Main class:' to 'io.vertx.core.Launcher',
input 'run cchcc.hi.HiVerticle' at 'Program arguments:' -> 'OK'
Run and Debug!
result
I would suggest what Fran already hinted at. Best you create your Maven project from the archetype (http://vertx.io/maven_dev.html) such as
and add the IDE specifics via maven, for example for Eclipse
By that you have an ready to import and ready to use project in Eclipse.
To actually start it then, I wouldn't go directly for a Main or Starter Verticle as but just simple run it through Maven in Eclipse as new Run Configuration. Create a new Maven Run Configuration and set as goals
It will start the mod.json configured "Main" class.
Note: clean compile is not necessary, but if you build it once and have installed jars of your project running around, the auto-deploy doesn't work anymore as it picks the build instead of the developed code.
Like that you have the example PingVerticle directly running and can also fool around as auto-redeploy is enabled in the mod.json.
If you then need more, configs etc. you can work with Starter Verticles, the parameters or even add it to the pom.xml vertx-maven-plugin.
I hope this helps.
Best
create a maven project as the manual says.
Then import the project as Maven project
Create a new launcher (Eclipse) using as main class
In the tab "Program Arguments" type: "run your.package.ServerVerticle -conf conf.json"
You can omit the conf.json if you don't have one, it's just an example to show you that you can put there any other option you'd put launching Vert.x from the command line.
PRO TIP: if your verticle is written in another language, use the prefix with the name of the language as follows:
And so forth.
If you are looking for options apart from creating a maven project (suggested in the other answers), you could do the following: