Introduction to JVM Languages
上QQ阅读APP看书,第一时间看更新

Running JVM applications on the command line

Running applications on a JVM is often considered a fairly complex topic. As mentioned in the previous chapter, compilers that target a JVM compile their source code to binary files with a .class file extension. There are a few rules that must be followed before you can have a JVM instance run the code inside the .class files:

  • At least one class must have a static main() method
  • All the class files should be stored in specific directories
  • The ClassPath has to be specified
  • Class files can optionally be placed inside a JAR archive container
  • To run the program, the java command is used

We will take a quick look at each rule. Then, to demonstrate these concepts as clearly as possible, we will be doing a hands-on demonstration project in Java.