4 ms·
1. Write a file `HelloWorld.java`. 2. Compile it to bytecode (.class file): `javac HelloWorld.java`. 3. Run it: `java HelloWorld.class`. If you want to use o
by deepsun 5y ago
1. Write a file `HelloWorld.java`.
2. Compile it to bytecode (.class file): `javac HelloWorld.java`.
3. Run it: `java HelloWorld.class`.
If you want to use other libraries, add `-cp` parameter ("cp" stands for "classpath").
If you want to package your code as a library, run `jar HelloWorld.class` (.jar is basically .zip renamed).
- laurent92 5y agoAnd if you want a webapp, use SpringBoot.
- kaba0 5y agoHell, you don’t even have to compile it anymore — java HelloWorld.java just does the thing you wrote. Also note that `java HelloWorld` looks for classes, so if you are in the same directory as the classfile, .class is not required.