无需互联网安装 Java

无需互联网安装 Java

我目前在 PC 上运行的是 Ubuntu GNOME 16.10,但不幸的是,我没有互联网连接。我真的非常需要能够在其上运行 Java 程序,因为我已经开始学习 Java。我的手机有互联网连接。有没有什么方法可以在没有互联网连接的情况下将 Java 下载到手机上,然后手动将其安装在 PC 上?

答案1

从 ORACLE 网站下载 java SE(zip 或 tgz),找到一种方法将打包的文件放在 Ubuntu 机器上,然后解压它。

假设你在 /opt/jdk_xyz 解压

然后在你的主目录中的 .bashrc 文件中添加以下内容

导出JAVA_HOME=/opt/jdk_xyz 导出PATH=$PATH:$JAVA_HOME/bin

答案2

这是什么类型的手机?您应该能够在手机上设置热点并将其连接到计算机。

答案3

VIA DPKG(推荐)

要安装 Java JDK:


威盛TAR.GZ

TecMint

  • 使用以下命令下载 Java SE 开发工具包:

    mkdir -p /opt/java && cd /opt/java && wget --header='Host: download.oracle.com' --header='User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0' --header='Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8' --header='Accept-Language: en-US,en;q=0.5' --header='Referer: http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html' --header='Cookie: s_cc=true; s_nr=1498980917874; gpw_e24=http%3A%2F%2Fwww.oracle.com%2Ftechnetwork%2Fjava%2Fjavase%2Fdownloads%2Fjdk8-downloads-2133151.html; s_sq=%5B%5BB%5D%5D; mmapi.store.p.0=%7B%22mmparams.d%22%3A%7B%7D%2C%22mmparams.p%22%3A%7B%22pd%22%3A%221530516890611%7C%5C%22-1391031818%7CAgAAAApVAgBicrOD%2Bw4AARAAAUL58MllAQBg%2BanSHMHUSMBunc0cwdRIAAAAAP%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAZEaXJlY3QB%2Bw4BAAAAAAAAAAAA%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2F%2FAAAAAAAAAAFF%5C%22%22%2C%22srv%22%3A%221530516890619%7C%5C%22lvsvwcgus07%5C%22%22%7D%7D; mmapi.store.s.0=%7B%22mmparams.d%22%3A%7B%7D%2C%22mmparams.p%22%3A%7B%7D%7D; oraclelicense=accept-securebackup-cookie' --header='Connection: keep-alive' --header='Upgrade-Insecure-Requests: 1' 'http://download.oracle.com/otn-pub/java/jdk/8u131-b11/d54c1d3a095b4ff2b6607d096fa80163/jdk-8u131-linux-x64.tar.gz?AuthParam=1498981040_490f55b758f4176934eced4b212765c4' -O 'jdk-8u131-linux-x64.tar.gz' -c
    
  • 提取文件:

    tar -xvzf jdk-8u131-linux-x64.tar.gz
    
  • 更改目录:

    cd jdk1.8.0_131/
    
  • 更新替代方案:

    sudo update-alternatives --install /usr/bin/java java /opt/java/jdk1.8.0_45/bin/java 100 && sudo update-alternatives --config java && sudo update-alternatives --install /usr/bin/javac javac /opt/java/jdk1.8.0_45/bin/javac 100 && update-alternatives --config javac && sudo update-alternatives --install /usr/bin/jar jar /opt/java/jdk1.8.0_45/bin/jar 100 && sudo update-alternatives --config jar
    
  • 设置环境变量:

    sudo export JAVA_HOME=/opt/java/jdk1.8.0_131/ && sudo export JRE_HOME=/opt/java/jdk1.8.0_131/jre && sudo export PATH=$PATH:/opt/java/jdk1.8.0_131/bin:/opt/java/jdk1.8.0_131/jre/bin 
    
    • 或者更好的方法是全局设置环境变量:
      • 编辑/etc/environment并添加以下行:
        • JAVA_HOME=/opt/java/jdk1.8.0_131/
        • JRE_HOME=/opt/java/jdk1.8.0_131/jre
        • PATH=$PATH:/opt/java/jdk1.8.0_131/bin:/opt/java/jdk1.8.0_131/jre/bin
      • 重新启动系统。

相关内容