Bootstrap

信创问题系列-openjdk替换oracle-jdk

信创问题系列-openjdk替换oracle-jdk


使用场景

客户现场信创任务:要把oracle-jdk 换成openjdk,把tomcat/weblogic 换成 宝兰德中间件,把oracle数据库 换成 gaussdb(华为高斯)、gbase、达梦数据库。我所在的项目组选型是 openjdk + 宝兰德 + gaussdb ;
准备在本地开发环境测试用openjdk 编译之前的代码,看看有没有啥报错,为后续生产部署应用打好基础;


一、openjdk1.8这里下在的是32bit的,如果使用这个版本的jdk编译代码,Tomcat启动应用,报错

网站:openjdk下载
在这里插入图片描述

12-Jan-2023 14:59:45.586 警告 [main] org.apache.catalina.core.AprLifecycleListener.init The APR based Apache Tomcat Native library failed to load. The error reported was [D:\apache-tomcat-8.0.53\bin\tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform]
 java.lang.UnsatisfiedLinkError: D:\apache-tomcat-8.0.53\bin\tcnative-1.dll: Can't load AMD 64-bit .dll on a IA 32-bit platform
	at java.lang.ClassLoader$NativeLibrary.load(Native Method)
	at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1937)
	at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1855)
	at java.lang.Runtime.loadLibrary0(Runtime.java:842)
	at java.lang.System.loadLibrary(System.java:1134)
	at org.apache.tomcat.jni.Library.<init>(Library.java:42)
	at org.apache.tomcat.jni.Library.initialize(Library.java:178)
	at org.apache.catalina.core.AprLifecycleListener.init(AprLifecycleListener.java:197)
	at org.apache.catalina.core.AprLifecycleListener.isAprAvailable(AprLifecycleListener.java:106)
	at org.apache.catalina.connector.Connector.setProtocol(Connector.java:564)
	at org.apache.catalina.connector.Connector.<init>(Connector.java:66)
	at org.apache.catalina.startup.ConnectorCreateRule.begin(ConnectorCreateRule.java:62)
	at org.apache.tomcat.util.digester.Digester.startElement(Digester.java:1181)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.startElement(AbstractSAXParser.java:509)
	at com.sun.org.apache.xerces.internal.parsers.AbstractXMLDocumentParser.emptyElement(AbstractXMLDocumentParser.java:182)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanStartElement(XMLDocumentFragmentScannerImpl.java:1343)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2786)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:606)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:510)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:848)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:777)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:141)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1213)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:649)
	at org.apache.tomcat.util.digester.Digester.parse(Digester.java:1449)
	at org.apache.catalina.startup.Catalina.load(Catalina.java:564)
	at org.apache.catalina.startup.Catalina.load(Catalina.java:615)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:497)
	at org.apache.catalina.startup.Bootstrap.load(Bootstrap.java:308)
	at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:482)

二、解决 java.lang.UnsatisfiedLinkError: D:\apache-tomcat-8.0.53\bin\tcnative-1.dll: Can’t load AMD 64-bit .dll on a IA 32-bit platform

1.win + r
2.cmd 看看java 版本

C:\Users\Administrator>java -version
openjdk version "1.8.0_42"
OpenJDK Runtime Environment (build 1.8.0_42-b03)
OpenJDK Client VM (build 25.40-b25, mixed mode)  
#上面这一行没写是64bit 就是32bit的

重新搜openjdk,最后找了两个
Liberica JDK:https://bell-sw.com/pages/downloads/#downloads (full版 这个网站好下载)自己就能下
在这里插入图片描述

Eclipse Temurin 是由基于 OpenJDK 的开源 Java SE 产生的构建版本。Temurin 适用于 广泛的平台 以及诸多 Java SE 版本。
https://adoptium.net/zh-CN/temurin/releases/?version=8 (下载难)
在这里插入图片描述
★ C站有积分的来这里👇:
OpenJDK8U-jdk-x64-windows-hotspot-8u352b08-3.zip
★ 白嫖党自取👇:
蓝奏云

windows安装openjdk步骤和安装oracle-jdk一样,此处省略

Microsoft Windows [版本 10.0.19045.2364]
(c) Microsoft Corporation。保留所有权利。

C:\Users\Administrator>java -version
openjdk version "1.8.0_352"
OpenJDK Runtime Environment (Temurin)(build 1.8.0_352-b08)
OpenJDK 64-Bit Server VM (Temurin)(build 25.352-b08, mixed mode)
#是64bit
C:\Users\Administrator>

2.1 修改idea jdk的版本

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.1 修改idea tomcat的jre版本

在这里插入图片描述
编译成功,启动tomcat看有无报错

★★★★★★★成功★★★★★★★★

总结

以上就是今天要分享的内容了,本文介绍了openjdk替换oracle-jdk
;