Location>code7788 >text

Java Development Environment Installation Notes

Popularity:323 ℃/2024-08-11 10:45:23

catalogs
  • JDK version
    • Java 8
    • Java 9
    • Java 11 (LTS)
    • Java 17 (LTS)
    • Java 21
  • JDK environment variable settings
    • JAVAHOME and PATH environment variables
    • JAVAPATH environment variable
  • Multiple SDK version switching


Another double-boot of a new computer, and another double-boot of having to re-toss all sorts of software installations, for the record...

Software installation, the most troublesome than the JAVA programming environment installation, Java runtime environment to distinguish between JDK and JRE, the difference is:

  • The JDK is positioned to givedeveloperswhich has a lot of programming related interfaces to use, and also provides thecompilingand such functions;
  • The JRE is positioned to giveregular userThe ones that use it, they just need the software out of the box (that is, just click on the .jar package and it's going to run right away), they don't care about interfaces, compilation.

JDK version

The Java JDK has iterated through many versions over the years. In general, each version has specific needs and tasks, and the differences and distinctions between versions of the Java SDK are mainly in language features, performance improvements, security enhancements, and the introduction of new tools. The following are some of the key version features:

Java 8

  • Lambda Expressions: Introduce functional programming support.
  • Stream API: A declarative way of dealing with collections.
  • New Date Time API: Improve date and time processing.

Java 9

  • modular system: Introduction of a modular system (Project Jigsaw).
  • JShell: Interactive programming tools.
  • Improved Javadoc: Supports the search function.

Java 11 (LTS)

  • Local Variable Syntaxvar Used for local variable type inference.
  • HTTP Client: Improved HTTP API.
  • Removing Tools and APIs: such as JavaFX and CORBA.

Java 17 (LTS)

  • pattern matching: Pattern matching for switch.
  • Seals: Controls which classes can be extended.
  • text block: Simplify multi-line string definitions.

Java 21

  • New Language Features: More experimental features may be introduced.
  • performance optimizationcap (a poem)security enhancement

The current mainstream version:
Broadly speaking, Java 17 is the latest Long Term Support (LTS) release.

JDK environment variable settings

JAVAHOME and PATH environment variables

If you want to run the execution of java commands, you have to tell the system environment where the java bin directory is, the bin directory contains executable files such as the Java compiler. Here is how to configure it:

Configuration method:
Create a new environment variable in the system environment variable: JAVAHOME
Value: D:\home\program\code\jdk\jdk-17; (that's your local javaSDK path)

Then add a value to the PATH environment variable:
%JAVA_HOME%/jre/bin;

JAVAPATH environment variable

When you run a file, if the program depends on other classes or libraries that are not in the current directory, Java needs to know where to look for them. To ensure that your program runs correctly, Java needs to know where to look for these dependencies.

Where to find dependency?
Screw your configuration.CLASSPATH environment variableIf you don't configure this environment variable, then Java will default to the.The current directory is the JAVACLASS path.

If the .jar package does not depend on libraries in other paths, then thisCLASSPATH environment variableThere would be no use.

Configuration method:
Create a new environment variable in the system environment variable: CLASSATH

Value:
.;
%JAVA_HOME%\lib;
%JAVA_HOME%\lib\;
%JAVA_HOME%\lib\

Multiple SDK version switching

The idea is to just switch the JAVAHOME environment variable.