[Java] Flow from source code to execution

Flow from source code to execution

  1. Creating source code
  2. Compile
  3. Run

Simply put, this is the procedure: smile: As a beginner, it was refreshing to say: thinking: What is compilation? ?? ?? It's like: sweat_smile:

I would like to explain what it is like little by little: smile: I think it's probably like this Please point out any misunderstandings: smile:

1. Source code creation → 2. Compile

Many people know the source code, don't they? The following programs we create: smile:

Example.java


public class Main {
	public static void main(String[] args) {
		System.out.println("hello, world!");
	}
}

Well, this program. Even if we write the code neatly, unfortunately the computer cannot understand it as it is: rolling_eyes:

Even if you talk to foreigners who don't understand Japanese in Japanese, they won't understand it: sweat_smile:

english_kaiwa_bad_man.png

So what should I do ... I think it's easier to get an image if you anthropomorphize: smile:

It would be nice to have someone who understands each other's words come in and translate: laughing:

The equivalent of that interpreter is compilation: laughing:

おじさんわらう.png

This compilation has the feature of ** translating source code written by humans into machine language **.

: bulb: ** Compile features **: bulb: : sunny: Convert source files to class files : sunny: The converted class file contains what is called bytecode. : sunny: Compile uses software called a compiler to do the above work. : sunny: The compiler also checks the grammar of the source code

Converting a source file to a class file means File name.java → File name.class It means to convert the extension to.

The extension is .Txt for notes .Docx for Word .Xlsx for Excel .Pdf for PDF Etc., which is listed after the file name.

Let's get back to the story: smile:

And there is something called a bytecode in the one converted into a class file, but this ** bytecode is a complex array of 0s and 1s **. In other words, the source code we created is converted into the one formed by 0s and 1s.

file name source file Class file
The contents of the file Source code Bytecode

If I change the source file to a class file, should I modify the file extension? : thinking:

I think that, but it will probably be an error.

What to do is to use software called a compiler. Compiler for compilation ... confusing: sweat_smile:

Well, this compiler. It also checks the grammar of the source code we create.

Hey, isn't the English spelling wrong? Hey, isn't it cool?

Etc. will be checked. By the way, it won't compile until I fix these. You will be sent back all the time: sweat_smile:

2. Compile → 3. Execute

I had them translated into the words of the machine, and finally the program was executed! : fist: I think, but wait a minute! : hand_splayed :.

In fact, it still doesn't work at this rate. You can't do it because you converted it into machine language! ?? !! ?? I think. At least I thought: sweat_smile:

Compared to the source code, it looks like it can be executed, but it cannot be executed.

When I think about it again as anthropomorphic, the compilation uncle who translated it earlier. It's nice that he translated it, but the dialect was too tight to convey to the other party ... I think it's like: sweat_smile:

おじさんてへぺろ.png

In that case, we need someone who can translate this compilation uncle's dialect into standard language. that is···

おんなわらう.png

Interpreter: smile:

: bulb: ** Interpreter features **: bulb: : sunny: Request bytecode conversion and execution : sunny: Has a mechanism called JVM

The bytecode translated by the compilation uncle is converted into a machine language called machine code by the interpreter.

Send this translated machine code to the CPU for processing. (The CPU has the function of understanding the machine code in the brain part of the personal computer and executing and calculating instructions.)

** JVM is to have the CPU execute instructions while reading bytecode little by little. ** **

For example

Example.


Where is here?
How do I get to the station?
How long does it take to get to the station?

Suppose you ask the question. Then ...

Where is here? ↓ translation ↓ New York

How do I get to the station? ↓ translation ↓ Turn left at the next corner and stay straight

How long does it take to get to the station? ↓ translation ↓ It's about 10 minutes.

Does it feel like a simultaneous interpreter as an image? ?? Instead of listening to the other person's story and then translating it It's like interpreting while listening to the story.

Java programs are executed in this way: smile:

By the way, this interpreter is also one of the software along with the compiler. So you can't use Java without installing the compiler and interpreter.

Recommended Posts

[Java] Flow from source code to execution
Changes from Java 8 to Java 11
Sum from Java_1 to 100
Eval Java source from Java
From Java to Ruby !!
Migration from Cobol to JAVA
New features from Java7 to Java8
Connect from Java to PostgreSQL
From Ineffective Java to Effective Java
How to decompile apk file to java source code with MAC
Code Java from Emacs with Eclim
Java to be involved from today
From Java to VB.NET-Writing Contrast Memo-
Java source code reading java.lang.Math class
Java, interface to start from beginner
Switch from Eclipse to VS Code
The road from JavaScript to Java
[Android] Convert Android Java code to Kotlin
[Java] Conversion from array to List
Sample code using Minio from Java
Basic structure of Java source code
Install samba4 from source code on CentOS8
[JAWS-UG CLI] CodeBuild: # 1 Creating Source Code (Java)
How to call Swift 5.3 code from Objective-C
[Java] How to measure program execution time
Connect from Java to MySQL using Eclipse
From installing Eclipse to executing Java (PHP)
Post to Slack from Play Framework 2.8 (Java)
Java: How to send values from Servlet to Servlet
Introduction to monitoring from Java Touching Prometheus
I tried to build Ruby 3.0.0 from source
Precautions when migrating from VB6.0 to JAVA
Memo for migration from java to kotlin
Execute Java code from cpp with cocos2dx
Type conversion from java BigDecimal type to String type
[Java] Flow from introduction of STS to confirmation of dynamic page on localhost (2/3)
[Java] Flow from introduction of STS to confirmation of dynamic page on localhost (1/3)
[Rspec] Flow from introducing Rspec to writing unit test code for a model
Generate source code from JAR file with JD-GUI of Java Decompiler project
What is CHECKSTYLE: OFF found in the Java source? Checkstyle to know from
[Java] From two Lists to one array list
Upsert from Java SDK to Azure Cosmos DB
Script Java code
Connect to Aurora (MySQL) from a Java application
To become a VB.net programmer from a Java shop
Java sample code 02
Code to escape a JSON string in Java
Java sample code 03
Migrate from Java to Server Side Kotlin + Spring-boot
[Java] Convert DB code to code value using enum
How to get Class from Element in Java
Java sample code 04
[Java] Introduction to Java
I want to write quickly from java to sqlite
Introduction to java
Java sample code 01
Java character code
Clean up findViewById from source code with DataBindingLibrary
Minecraft BE server development from PHP to Java
[Java] Memo on how to write the source
What is ... (3 dots) found in the Java source? Variadic arguments to know from