Sometimes it's nice to log things to the console during development. In a Vert.x 3 project I'm creating, I'm trying to follow the instructions on the docs page for Vert.x 3 for logging:
http://vert-x3.github.io/docs/vertx-core/js/#_logging_from_your_application
The docs provide this sample code:
// Note -these classes are Java only
// You would normally maintain one static instance of Logger per Java class:
var logger = Java.type("io.vertx.core.logging.LoggerFactory").getLogger(className);
logger.info("something happened");
logger.error("oops!", exception);
When compiling, the "var logger = ..." line bombs out with this error:
Failed in deploying verticle java.lang.RuntimeException: java.lang.ClassNotFoundException: io.vertx.core.logging.LoggerFactory at jdk.nashorn.internal.runtime.ScriptRuntime.apply(ScriptRuntime.java:391) at jdk.nashorn.internal.scripts.Script$Recompilation$13$1895AAAAA$\^eval_.L:27$_load(null:107) at jdk.nashorn.internal.scripts.Script$Recompilation$4$4036AAAA$\^eval_.L:27$doRequire(null:149) at jdk.nashorn.internal.runtime.ScriptFunctionData.invoke(ScriptFunctionData.java:644) at jdk.nashorn.internal.runtime.ScriptFunction.invoke(ScriptFunction.java:229)
(Note: that "className" variable looks suspicious too. It doesn't say anywhere what that's supposed to be, it's "undefined" at compile time at the moment)
Any ideas?
This is due to versions getting slightly out of sync in the Vertx 3 milestones. The documentation already reflects a change upcoming in milestone 7 where the class package is:
However, in milestone 6 you need to use:
If you update your code to:
it should work.