
Mkyong.com
1000 FOLLOWERS
Mkyong.com is providing Java and Spring tutorials and code snippets since 2008. All published articles are simple and easy to understand and well tested in our development environment.
Mkyong.com
2M ago
Java 19 reached general availability on 20 September 2022, download Java 19 here.
Java 19 has 7 JEP items.
1. JEP 405: Record Patterns (Preview)
1.1 Normal Record Patterns Example
1.2 Record Nested Patterns Example
2. JEP 422: Linux/RISC-V Port
3. JEP 424: Foreign Function & Memory API (Preview)
4. JEP 425: Virtual Threads (Preview)
5. JEP 426: Vector API (Fourth Incubator)
6. JEP 427: Pattern Matching for switch (Third Preview)
7. JEP 428: Structured Concurrency (Incubator)
Download Source Code
References
Java 19 developer features.
Record Patterns (preview), Foreign Function & ..read more
Mkyong.com
2M ago
This article show you how to find all packages installed using Homebrew?
1. brew list
Open the Terminal and runs the command brew list to list all the installed packages using Homebrew.
Terminal
% brew list
==> Formulae
aom curl giflib imath libevent libssh2 maven
==> Casks
adoptopenjdk rar temurin temurin18
2. brew deps –tree –installed
Open the Terminal and runs the command brew deps --tree --installed to list all installed packages and their dependencies in a tree format.
Terminal
% brew deps --tree ..read more
Mkyong.com
2M ago
Java 18 reached general availability on 22 March 2022, download Java 18 here.
Java 18 has 9 JEP items.
1. JEP 400: UTF-8 by Default
2. JEP 408: Simple Web Server
3. JEP 413: Code Snippets in Java API Documentation
4. JEP 416: Reimplement Core Reflection with Method Handles
5. JEP 417: Vector API (Third Incubator)
6. JEP 418: Internet-Address Resolution SPI
7. JEP 419: Foreign Function & Memory API (Second Incubator)
8. JEP 420: Pattern Matching for switch (Second Preview)
8.1. Dominance checking of the same type.
8.2 Exhaustiveness of switch expressions and statements
9. JEP 421: Depr ..read more
Mkyong.com
2M ago
After upgrading to macOS Big Sur 11, macOS Monterey 12, macOS Ventura 13, etc. Does it seem every upgrading macOS will cause the following error message for the git command? How to fix it?
Terminal
% git
xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools),
missing xcrun at: /Library/Developer/CommandLineTools/usr/bin/xcrun
Solution
Open the Terminal, and run this
Terminal
xcode-select --install
The above command will install the command line developer tools.
Follow the GUI guide and proceed with the installation; this should fix the git xcrun error ..read more
Mkyong.com
5M ago
I migrated from Spring 3 to Spring 5 and found out the WebMvcConfigurerAdapter class is deprecated; what should we do?
SpringWebConfig.java
package com.mkyong.helloworld.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
import org ..read more
Mkyong.com
5M ago
It means Java 17 (major version 61) compiled the class file, and if we try to run the class file under Java 16 and below environment, and we will hit Unsupported class file major version 61.
1. Find the major version of the Java class file
Every compiled Java class file, or .class has a major version to tell which Java version compiled the class; For example, Java 17 (major version 61), Java 11 (55), Java 8 (52).
Java SE
Major Version
Hex
17
61
0x3D
11
55
0x37
9
53
0x35
8
52
0x34
Note
Review this table for a complete list of a major versions of the Java class file.
2. Unsuppo ..read more
Mkyong.com
5M ago
This article shows all the major version of the Java class file, for example, Java 17 (major version 61), Java 11 (55), Java 8 (52).
Java SE
Major Version
Hex
18
62
0x3E
17
61
0x3D
16
60
0x3C
15
59
0x3B
14
58
0x3A
13
57
0x39
12
56
0x38
11
55
0x37
10
54
0x36
9
53
0x35
8
52
0x34
7
51
0x33
6.0
50
0x32
5.0
49
0x31
1.4
48
0x30
1.3
47
0x2F
1.2
46
0x2E
1.1
45
0x2D
javap to print Java class file
In Java, we can use the javap command tool to find the major version of the Java class file.
Terminal
% javap -verbose ClassName | grep major
major version: 61 ..read more
Mkyong.com
5M ago
In the Spring framework, the @RequestBody annotation maps the web request’s body to the method’s parameter, usually a domain object or a Map.
Table of contents
1. Spring @RequestBody example
2. Spring @RequestBody example – Map version
3. Download Source Code
4. References
1. Spring @RequestBody example
Below is a @RequestBody example to map the request body (usually JSON data) to the method parameter LoginObject.
LoginObject.java
package com.mkyong;
public class LoginObject {
private String username;
private String password;
public LoginObject(String username, String password ..read more
Mkyong.com
5M ago
This article shows you what @Controller and @RestController are and their differences.
Table of contents:
1. Spring @Controller annotation
2. Spring @RestController annotation
3. Download Source Code
4. References
1. Spring @Controller annotation
Spring 2.5 introduced the @Controller as the web controller for the MVC architecture. Spring 3.0 introduced the @ResponseBody to return the method’s return type directly into the HTTP response body. We can combine both @Controller and @ResponseBody to quickly create RESTful web services.
For example:
HelloController.java
import org.springframework ..read more
Mkyong.com
6M ago
In the IntelliJ IDEA, clicks on the download sources, and it shows the error Cannot connect to the Maven process.
Terminal
Cannot connect to the Maven process. Try again later.
If the problem persists, check the Maven Importing JDK settings and restart IntelliJ IDEA
Tested with
IntelliJ IDEA 2022.2.1 (Community Edition)
Build #IC-222.3739.54, built on August 16, 2022
Solution
To fix it, we switch from the default "Bundled Maven 3" option to the manually installed Maven path.
In IntelliJ IDEA, click Preferences, Build Tools -> Maven
Change to other Maven installed path.
Reference ..read more