java hello world, compile, run

I completely forgot, so I remember it again.

There is main () in class.

The class name and file name should be the same, and the extension is class name.java.

Compile to create classname.class

** Execute with java class name without extension! !! !! ** **

$ cat HelloWorld.java
public class HelloWorld {
	public static void main(String[] args) {
		System.out.println("Hello World!");
	}
}

#compile
$ javac HelloWorld.java


#File is created
$ ll HelloWorld.class
-rw-r--r--  1 root  staff   426B  2  1 15:18 HelloWorld.class

#No extension is added at runtime! !! !!
$ java HelloWorld
Hello World!

#When I add an extension, I get this error
$ java HelloWorld.class
error:Main class Hello World.Could not find and load class
Cause: java.lang.ClassNotFoundException: HelloWorld.class

Recommended Posts

java hello world, compile, run
Java, Hello, world!
Java Hello World
"Hello World" in Java
Java Learning (1)-Hello World
Java development with Codenvy: Hello World! Run
Java beginners read Hello World
Hello World for ImageJ Java Plugin
Hello World on AWS Lambda + Java
Hello World in java in eclipse now
Hello world in Java and Gradle
Hello world with Java template engine Thymeleaf
Read "Hello world"
Hello World on Mac VS Code Java
Hello Java Lambda
Minimal Java environment construction and Hello World
Build Java environment and output hello world [Beginner]
Run JSP Hello World with Tomcat on Docker
[Java] Hello World with Java 14 x Spring Boot 2.3 x JUnit 5 ~
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Compile and run Java on the command line
Wastefully creative "Hello World" output method list (Java)
Run PostgreSQL on Java
Read System.out.println ("hello, world")
Let's write Hello World
Hello world in node.js
Studying Java-Part 1-Hello World
Hello World on WebAssembly
Hello World with Micronaut
Hello World with Spring Boot
Run batch with docker-compose with Java batch
[Java] One type of alphabet prohibited With binding Hello, world! [Binding]
Java history in this world
Hello World with Spring Boot!
Hello World with VS Code!
Run java applet on ubuntu
Hello World with Spring Boot
Try Hello World using plain Java on a Docker container
Hello World with SpringBoot / Gradle
Run Java VM with WebAssembly
Hello, World! With Asakusa Framework!
Until you run Hello World of JavaFX with VS Code + Gradle
Try Hello World with the minimum configuration of Heroku Java spring-boot
Compare Hello, world! In Spring Boot with Java, Kotlin and Groovy
Java 10 (JDK 10) was released on March 20, 2018, so let's try Hello World.
Run Java EE applications on CICS
Spring Boot Hello World in Eclipse
Compile Java at the command prompt
[For beginners] Run Selenium in Java
Run Java application in Azure Batch
Until "Hello World" with Spring Boot
Run node.js from android java (processing)
Run a batch file from Java
Hello world with Kotlin and JavaFX
Hello World with Docker and C
(Intellij) Hello World with Spring Boot
Run tomcat shell script on java8
Hello World with GlassFish 5.1 + Servlet + JSP
Create PDF with itext7 ~ Hello World ~
hello, world in Vanilla Java-EHW2018 "MVP"