In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces how to install J2SE, the article is very detailed, has a certain reference value, interested friends must read it!
The so-called J2SE full name is The JavaTM 2 Platform, Standard Edition, now the latest version is 1.3.1, a variety of operating systems (Solaris SPARC/x86, Linux, Windows), there is a corresponding J2SE, you can go to Sun's website Download (http://java.sun.com/j2se/1.3/).
Installation:
Install J2SE on Linux:
There are two versions of the Sun website available for download, one in RedHat RPM shell script and the other in GNUZIP Tar shell script. Before starting Anzang, please change the user to su.
RedHat RPM shell script:
Execute the downloaded file:
Change to the directory of the file and execute:
. / j2sdk-1_3_1-linux-i386-rpm.bin
The file is a shell script, so please make sure that the file has the permission to execute before execution.
Chmod + x j2sdk-1_3_1-linux-i386-rpm.bin
Or directly use
Sh j2sdk-1_3_1-linux-i386-rpm.bin
To execute.
After reading License's announcement, of course, it is yes. At this time, it will begin to decompress. After completion, a rpm file jdk-1.3.1.i386.rpm will appear under the same path, and then execute:
Rpm-ivh jdk-1.3.1.i386.rpm
It will be installed. If there is an error message saying that there is a problem with dependence, you can add-- nodeps's option.
Rpm-ivh jdk-1.3.1.i386.rpm-- nodeps
When finished, JDK is installed in / usr/java/jdk1.3.1. Remember to add / usr/java/jdk1.3.1/bin to PATH.
GNUZIP Tar shell script:
Execute the downloaded file:
Change to the directory of the file, and before running the program, decide where you want to install JDK, because after executing the shell script, jdk1.3.1 will be installed in the path where the installation was performed.
So please decide the path to install first, move j2sdk-1_3_1-linux-i386.bin to this directory, and execute:
. / j2sdk-1_3_1-linux-i386.bin
Similarly, please first determine whether the file has permission to execute.
After reading the License, the same key is entered into the yes, and the decompression begins. After completion, another directory will be added to the jdk1.3.1 directory, that is, the installation is complete. Also remember to add bin under jdk1.3.1 to PATH.
Install J2SE on Windows:
The JDK installation of windows is simple, as long as you execute the downloaded file and follow the instructions, I won't repeat it here.
The directory architecture of J2SE (take windows as an example):
After installation, the structure of the directory is as follows:
Jdk1.3.1 is the root directory of the installation
The following is an introduction to some important directories:
Jdk1.3.1in:
All the tools that developers need here are executable files, such as java, javac, javah, rmic, rmiregistry and so on, so it is best to add only paths to PATH.
Jdk1.3.1lib:
The files needed by the development tool, such as tools.jar,dt.jar, and jdk1.3.1 also put the htmlconverter.jar in, so you don't have to download it separately.
Jdk1.3.1jre:
As the name implies, it is the root directory of runtime, which can be obtained from the property--java.home of the system when you run the java program.
Jdk1.3.1jrelib:
The files required by libraries and tools, there are some executable files and some dll files.
Jdk1.3.1jreinclassic:
The dll file used by Java 2 Classic Virtual Machinen.
Jdk1.3.1jreinhotspot:
The dll file used by Java HotSpotTM Client Virtual Machine.
Jdk1.3.1jrelib:
The library, property, and resources required by the main java runtime environment are all placed here.
Jdk1.3.1jrelibext:
Related to the extension mechanism, put some additional package jar files, or helper jar files. The jar file that you put here can be found when you execute java ten even though you didn't join the CLASSPATH.
Jdk1.3.1jrelibsecurity:
Store the files used by Security Manager, such as java.policy,java.security.
Settings after installation:
Set the PATH:
Add [JDK root] in to PATH first, so that you can run java programs by typing java directly from the command line. Because as mentioned before, under the bin directory are the tools for developing this, such as java, javac, javadoc, javah, rmic, and so on.
Set the CLASSPATH:
This setting is used when running a java program, where VM will find the class to be executed, or the class used in the program, which will later explain the mechanism by which java VM looks for class.
So if you have some class that you often use, or if you have to use another class to run a program, the easiest way to let java VM find the class you want to reference is to write that class into CLASSPATH. In addition, CLASSPATH is usually set up. (that is, the current path), and.. / (one level above the execution path). In addition, the separator for windows is a semicolon (;) and a semicolon (:) on linux.
For example:
In the environment of windows:
Set CLASSPATH=.;../;c:MyClass.class;c:MyJar.jar
Introduction of basic concepts:
Java is an object-oriented programming language. For java, a program we write is at least one class (meaning similar to a class, we will write class directly below), while class and class can inherit or reference each other (if there are no additional restrictions on the class to be referenced or inherited), while Java Platform roughly divides classes into three categories.
Bootstrap classes:
It is the basic classes that makes up the main Java Platform, contained in the two jar files rt.jar and i18n.jar, and placed in the [JDK root] jrelib directory. As long as you execute java, these classes can be found automatically.
Extension classes:
That is, under [JDK root] jrelibext, all .jar files, the so-called jar files, are actually a large collection of classes, using the tool---jar provided by java to compress a lot of class into a .jar file. Generally speaking, jar is actually a compression tool, so other files or resources needed for program execution can be placed in .jar, such as graphics files, plain text files, configuration files, and so on.
The jar file placed under [JDK root] jrelibext will also be found automatically by Java VM when it is executed.
(this is called Extension Mechanism.)
User classes:
The classes that developers or ordinary users want to use, there are two ways for Java VM to find these classes
Add the classes you want to use to the environment variable CLASSPATH.
Add the parameter-classpath to the command line of the running program to specify other classes. For example, when you want to execute MyClass.class, you need to use YourClass.class. I put YourClass.class under c:otherclasses and MyClass.class under c:myclasses, then execute the following instructions:
Java-classpath c:otherclasses c:myclassesMyClass
So when you write a new class, compile with javac, and execute with java, when ClassNotFountException appears, it means that the class you want to execute, or the referenced class,Java VM, is not found in the classes of the above three categories. The solution is to add the classes you want to use to the second and third types of classes, and execute it once.
A simple example:
Public class HelloWorld {
Public static void main (String [] args) {
System.out.println ("Hello Worldwide!")
}
}
Open any text editor at random, paste the above programs, and save the file as HelloWorld.java. Note that the case is different for java. After storage, go to console, change the path to the directory where the file is stored, and execute:
Javac HelloWorld.java
Then a HelloWorld.class file, the so-called class file, is generated under the same path, and then executes:
Java HelloWorld
It will output "Hello wordings!" in console. The string of. If you have any questions, refer to the post-installation settings and the basic concepts section.
The basic usage of Jar Tool:
Jar is a compression tool used to package a lot of classes into a jar file, that is, the basic principle is similar to that of zip, so the decompression tool used to unpack zip files can also unpack jar files. The main purpose of jar is to compress classes and speed up network download time. Basic usage:
Compress classes files
Jar cvf MyJar.jar c:myclasses*.class
C-create jar file, compress the file and generate the jar file.
V-verbose
F-specify the name of the file
The previous instruction means to package all class files under c:myclasses into MyJar.jar files and send messages to console during processing.
Unlock the jar file:
Jar xvf MyJar.jar
X-decompression
V-verbose
F-specify the name of the file
The last instruction was to unlock MyJar.jar to the current directory.
Jar tf MyJar.jar
T-View the contents of the Jar file
F-specify the name of the file
The last command is to view the files in MyJar.jar.
The above is all the contents of the article "how to install J2SE". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.