There are several good guides on creating Java Modules in IntelliJ IDEA including this one from JetBrains. Most guides including that one, however, stop short when it comes to actually firing up your Java App from the Command Line.
You can quickly run the app inside of IDEA, of course. Here’s what that would look like for our Hello World executing in the Run Window at the bottom of the screen.
But what about running it at the Command Line outside of IDEA?
First remember to use the fully qualified name of the Java class you just created. The fully qualified name of our HelloWorld class is com.nixmash.javasql.HelloWorld. In IntelliJ IDEA that would be located in /[project root]/src/com/nixmash/javasql. In our project src subdirectory, we’ll run our java app like so.
What happened? We need to compile our Java class for our Linux machine’s Java VM. If we look in our com.nixmash.javasql subdirectory we’ll find that we only have a .java file we created in IntelliJ. We need to create a HelloWorld.class file.
To find out what version of Java you’re using, use the -version parameter.
If we compile successfully there will be nothing but a happy prompt in response.
Okay, let’s do this!
My name is Dave. Hello!