SE450: Java Tools: java [34/41] ![]() ![]() ![]() |
To run java programs, you use the java runtime launcher. For the example above, you would run:
java Hello
Note that the .class is not included in the java command. This is assuming your classpath has been set to the directory where the .class files are located. To set it at runtime:
java -classpath c:\se450\build Hello
will work.
If you get something like:
Exception in thread "main" java.lang.NoClassDefFoundError: Hello
you didn't set your classpath correctly. Fix the classpath and it will work (or give you a different error)
To run the program that is in a package, you first need to ensure that the classpath contains the package root. Then run it as follows:
java example.Hello