Summary of problems in upgrading JDK from old version to 1.8
Jdk8 upgrade FAQ
JDK environment settings in IntelliJ
Settings
Click File > Settings > java compiler
Select 1.8 for project bytecode version
Click File > Settings > Build Tools > Maven > importing
Select JDK for importer as 1.8
Projcet Settings
Project SDK selection 1.8
Application
If the startup mode of the web application is application, the JRE needs to be modified
Click Run / debug configurations > configuration
Select JRE as 1.8
Linux environment modification
Modify environment variables
Modify Java in / etc / profile_ Home, set as jdk8 the path.
After modification, execute source / etc / profile to take effect.
Check whether the environment variable is added successfully test:
echo $JAVA_ HOME
If there is export Java in the compilation and release script_ Home. Note that you need to use the path of jdk8.
Modify maven
settings. If the activation condition of profile in XML is JDK, you need to modify the JDK version
<activation>
<jdk>1.8</jdk> <!-- 修改为 1.8 -->
</activation>
Modify server
Modify the javac version in the server. Take resin as an example:
Modify the javac parameters in the resin configuration file.
<javac compiler="internal" args="-source 1.8"/>
sun.* Package missing problem
Jdk8 no longer provides sun* The package is used by developers because these interfaces are not public interfaces and cannot be guaranteed to work on all Java compatible platforms.
Programs that use these APIs need to find alternatives if they want to upgrade to JDK 1.8.
Although, you can also import sun* The interface jar package to the classpath directory, but this is not a good practice.
You need to know why you don't use sun. *, Please refer to the official document: why developers should not write programs that call 'sun' packages
Default security policy modification
After the upgrade, it is estimated that some small partners may make errors when using unsafe algorithms. So, it is necessary to support unsafe algorithms
Found \ $Java_ JRE / lib / security / Java under home Security, set the disabled algorithm to null: JDK certpath. disabledAlgorithms= 。
JVM parameter adjustment
In jdk8, permsize related parameters are no longer used:
-XX:MaxPermSize=size
Sets the maximum permanent generation space size (in bytes). This option was deprecated in JDK 8, and superseded by the -XX:MaxMetaspaceSize option.
-XX:PermSize=size
Sets the space (in bytes) allocated to the permanent generation that triggers a garbage collection if it is exceeded. This option was deprecated un JDK 8, and superseded by the -XX:MetaspaceSize option.
Permgen is no longer available in jdk8. Some of them, such as the string interned, have been moved to the normal heap in JDK7. Other structures will be moved to the local memory area called "Metaspace" in jdk8. This area will grow automatically by default and will also be garbage collected. It has two Tags: metaspacesize and maxmetaspacesize.
-XX:MetaspaceSize=size
-XX:MaxMetaspaceSize=size
The following example shows how to set the upper limit of class metadata to 256 MB:
XX:MaxMetaspaceSize=256m
Bytecode problem
ASM 5.0 beta supports jdk8
Bytecode error
Caused by: java.io.IOException: invalid constant type: 15
at javassist.bytecode.ConstPool.readOne(ConstPool.java:1113)
<dependency>
<groupId>org.mvel</groupId>
<artifactId>mvel2</artifactId>
<version>2.2.7.Final</version>
</dependency>
<dependency>
<groupId>org.javassist</groupId>
<artifactId>javassist</artifactId>
<version>3.18.1-GA</version>
</dependency>
http://asm.ow2.org/history.html
Error in Java connection redis startup error redis clients jedis hostandport cant resolve localhost address
Error: there is no problem with the local window development environment. On the Linux environment, there is a problem starting. Error message: error redis clients jedis hostandport cant resolve localhost address
terms of settlement:
(1) View the host name of the Linux system
# hostname
template
(2) Check whether there is a host name corresponding to 127.0.0.1 in the / etc / hosts file. If not, add it
The resin container specifies JDK 1.8
If the original version of the resin container is lower than jdk1 8. When running the web app compiled by JDK 1.8, an error may be prompted:
java.lang.UnsupportedClassVersionError: PR/Sort : Unsupported major.minor version 52.0
The solution is to recompile using JDK 1.8. Then, I reported an error after compilation during deployment. After restarting the server, the problem was solved
./configure --prefix=/usr/local/resin --with-java=/usr/local/jdk1.8.0_121
make & make install