日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > windows >内容正文

windows

在window10 WSL 中编译 OpenJDK13

發(fā)布時間:2023/12/15 windows 42 豆豆
生活随笔 收集整理的這篇文章主要介紹了 在window10 WSL 中编译 OpenJDK13 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

簡介

最新的OpenJDK13已經(jīng)發(fā)布到git上,可以git pull,然后編譯了。

這里介紹了直接在windows 10 的WSL環(huán)境中進行build并測試。

準備

在Open JDK13的網(wǎng)站文檔中說,很簡單的幾步操作就好:

  • 下載源碼:
  • hg clone http://hg.openjdk.java.net/jdk/jdk

    好吧,這一步可能會攔住很多的愛好者。要成功clone下來源碼,很困難。

  • 執(zhí)行configure
    在源碼的目錄下,執(zhí)行configure命令
  • bash configure
  • 執(zhí)行make
  • make images
  • 驗證得到的JDK
  • .build/*/images/jdk/bin/java -version

    還可以執(zhí)行test驗證

    make run-test-tier1

    開始

    在第一步,要clone下來代碼,在國內(nèi)成功的可能性太低;
    可以利用gitee碼云來import在github上的openjdk的jdk13;然后再從gitee碼云上clone到本地。
    感謝碼云gitee。

    在github上的git 庫訪問地址,在gitee上import一下就OK了。

    https://github.com/openjdk/jdk13

    在第二步,在configure執(zhí)行時,會檢查很多的依賴項和命令。
    在執(zhí)行configure執(zhí)行,還執(zhí)行以下命令:

    sudo apt-get install libfreetype6-dev libcups2-dev libx11-dev libxext-dev libxrender-dev libxrandr-dev libxtst-dev libxt-dev libasound2-dev libffi-dev autoconf gcc clang libfontconfig1-dev

    然后,還需要安裝一下Boot-JDK; 安裝boot-JDK: java-12-jdk.
    Boot-JDK版本都是又要求的。一般要求是編譯版本N-1,有些也可以N -2.
    這里需要JDK12版本。

    sudo apt-get install openjdk-12-jdk

    現(xiàn)在,你可以開始執(zhí)行 ./configure

    錯誤

    開始檢查,可以缺少一下工具命令。比如zip、unzip……。

    這個你可以輕松地安裝搞定。

    然后,出現(xiàn)boot-jdk錯誤 :

    configure: Could not find a valid Boot JDK. OpenJDK distributions are available at http://jdk.java.net/. configure: error: Cannot continue configure: This might be fixed by explicitly setting --with-boot-jdk

    這是什么?然后你可能按照提示, 使用命令參數(shù) --with-boot-jdk指定安裝好的JDK。

    再執(zhí)行 ./configure --with-boot-jdk=/usr/lib/jvm/java-12-openjdk-amd64/
    繼續(xù)失敗。

    checking for jni library path... default checking if packaged modules are kept... yes (default) checking for version string... 13-internal+0-adhoc.david.jdk13 configure: Found potential Boot JDK using configure arguments configure: error: The path given by --with-boot-jdk does not contain a valid Boot JDK configure: Potential Boot JDK found at /usr/lib/jvm/java-12-openjdk-amd64/ did not contain bin/java; ignoring

    可boot-jdk就在那里!沒辦法,上午一番搜索。

    在網(wǎng)上找到設置unset _JAVA_OPTIONS
    繼續(xù)失敗。。

    方法

    沒有折了。看一下building文檔。里面針對window10 wsl,提到了需要特別注意的配置。

    Windows Subsystem for Linux (WSL)Windows 10 1809 or newer is supported due to a dependency on the wslpath utility and support for environment variable sharing through WSLENV. Version 1803 can work but intermittent build failures have been observed.It's possible to build both Windows and Linux binaries from WSL. To build Windows binaries, you must use a Windows boot JDK (located in a Windows-accessible directory). To build Linux binaries, you must use a Linux boot JDK. The default behavior is to build for Windows. To build for Linux, pass --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu to configure.

    按照說明,修改命令,再次執(zhí)行新命令:

    ./configure --build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu

    然后就看到了結(jié)果成功完成。

    執(zhí)行命令:

    config.status: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/Makefile... checking for which lcms to use... bundled checking for cos in -lm... yes checking for dlopen in -ldl... yes checking if shenandoah can be built... yes checking if zgc can be built... yes checking if jvmci module jdk.internal.vm.ci should be built... yes checking if graal module jdk.internal.vm.compiler should be built... yes checking if aot should be enabled... yes checking if cds should be enabled... yes checking if elliptic curve crypto implementation is present... yes checking if jtreg failure handler should be built... no, missing jtreg checking if the CDS classlist generation should be enabled... yes checking if any translations should be excluded... no checking if static man pages should be copied... yes checking if a default CDS archive should be generated... yes checking for number of cores... 8 checking for memory size... 8098 MB checking for appropriate number of jobs to run in parallel... 7 checking flags for boot jdk java command ... -Duser.language=en -Duser.country=US -XX:+UnlockDiagnosticVMOptions -XX:-VerifySharedSpaces -XX:SharedArchiveFile=/mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/configure-support/classes.jsa -Xshare:auto checking flags for boot jdk java command for big workloads... -Xms64M -Xmx1600M -XX:ThreadStackSize=1536 checking flags for bootcycle boot jdk java command for big workloads... -Xms64M -Xmx1600M -XX:ThreadStackSize=1536 checking flags for boot jdk java command for small workloads... -XX:+UseSerialGC -Xms32M -Xmx512M -XX:TieredStopAtLevel=1 checking whether to use sjavac... no checking whether to use javac server... yes checking If precompiled header is enabled... yes checking that precompiled headers work... yes checking is ccache enabled... no checking if build directory is on local disk... no checking JVM features for JVM variant 'server'... "aot cds cmsgc compiler1 compiler2 epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services shenandoahgc vm-structs zgc" configure: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/configure-support/config.status config.status: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/spec.gmk config.status: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/bootcycle-spec.gmk config.status: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/buildjdk-spec.gmk config.status: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/compare.sh config.status: creating /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release/Makefile==================================================== A new configuration has been successfully created in /mnt/d/openjdk13/jdk13/build/linux-x86_64-server-release using configure arguments '--build=x86_64-unknown-linux-gnu --host=x86_64-unknown-linux-gnu'.Configuration summary: * Debug level: release * HS debug level: product * JVM variants: server * JVM features: server: 'aot cds cmsgc compiler1 compiler2 epsilongc g1gc graal jfr jni-check jvmci jvmti management nmt parallelgc serialgc services shenandoahgc vm-structs zgc' * OpenJDK target: OS: linux, CPU architecture: x86, address length: 64 * Version string: 13-internal+0-adhoc.david.jdk13 (13-internal)Tools summary: * Boot JDK: openjdk version "12.0.2" 2019-07-16 OpenJDK Runtime Environment (build 12.0.2+9-Ubuntu-118.04) OpenJDK 64-Bit Server VM (build 12.0.2+9-Ubuntu-118.04, mixed mode) (at /usr/lib/jvm/java-12-openjdk-amd64) * Toolchain: gcc (GNU Compiler Collection) * C Compiler: Version 7.4.0 (at /usr/bin/gcc) * C++ Compiler: Version 7.4.0 (at /usr/bin/g++)Build performance summary: * Cores to use: 7 * Memory limit: 8098 MBWARNING: Your build output directory is not on a local disk. This will severely degrade build performance! It is recommended that you create an output directory on a local disk, and run the configure script again from that directory.

    等待半小時后,build完成

    Updating support/demos/image/jfc/Stylepad/src.zip Compiling 5 files for BUILD_DEMO_SampleTree Updating support/demos/image/jfc/SampleTree/src.zip Compiling 8 files for BUILD_DEMO_TableExample Updating support/demos/image/jfc/TableExample/src.zip Note: /mnt/d/openjdk13/jdk13/src/demo/share/jfc/Metalworks/MetalworksPrefs.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Compiling 1 files for BUILD_DEMO_TransparentRuler Updating support/demos/image/jfc/TransparentRuler/src.zip Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: /mnt/d/openjdk13/jdk13/src/demo/share/jfc/TableExample/TableExample4.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Note: /mnt/d/openjdk13/jdk13/src/demo/share/jfc/Stylepad/Stylepad.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Creating java.base.jmod Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. Note: Some input files use unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. Creating support/demos/image/jfc/CodePointIM/CodePointIM.jar Creating support/demos/image/jfc/FileChooserDemo/FileChooserDemo.jar Creating support/demos/image/jfc/Font2DTest/Font2DTest.jar Creating support/demos/image/jfc/SwingSet2/SwingSet2.jar Creating support/demos/image/jfc/J2Ddemo/J2Ddemo.jar Creating support/demos/image/jfc/Metalworks/Metalworks.jar Creating support/demos/image/jfc/Notepad/Notepad.jar Creating support/demos/image/jfc/Stylepad/Stylepad.jar Creating support/demos/image/jfc/SampleTree/SampleTree.jar Creating support/demos/image/jfc/TableExample/TableExample.jar Creating support/demos/image/jfc/TransparentRuler/TransparentRuler.jar Creating jdk image Creating CDS archive for jdk image Stopping sjavac server Finished building target 'images' in configuration 'linux-x86_64-server-release'

    測試一下java command:

    $ ./build/linux-x86_64-server-release/jdk/bin/java -version openjdk version "13-internal" 2019-09-17 OpenJDK Runtime Environment (build 13-internal+0-adhoc.david.jdk13) OpenJDK 64-Bit Server VM (build 13-internal+0-adhoc.david.jdk13, mixed mode)

    檢查javac command:

    $ ./build/linux-x86_64-server-release/jdk/bin/javac -version javac 13-internal

    測試一下編譯程序和執(zhí)行

    寫一個hello

    $ makedir samples $ vi samples\hello.java

    編寫最簡單的hello.java源碼:

    public class hello {public static void main(String[] args) {System.out.println("Hello, World ... ");} }

    編譯執(zhí)行:

    $./build/linux-x86_64-server-release/jdk/bin/javac samples/hello.java -d . $ ls hello.class hello.class$ ./build/linux-x86_64-server-release/jdk/bin/java hello Hello, World...

    以上,終于編譯成功了。

    總結(jié)

    以上是生活随笔為你收集整理的在window10 WSL 中编译 OpenJDK13的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。