简体   繁体   English

Ubuntu上的Javac

[英]Javac on Ubuntu

I'm on windows 10 and running the bash shell (ubuntu), by turning the Windows Subsystem for linux on. 我在Windows 10上并通过打开Linux的Windows子系统来运行bash shell(ubuntu)。 Anyways, I'm trying to run some Java programs through the command prompt. 无论如何,我试图通过命令提示符运行一些Java程序。 I have already set the PATH variables and I can successfully run the java and javac commands in the windows command prompt. 我已经设置了PATH变量,并且可以在Windows命令提示符下成功运行java和javac命令。 However, when I run the javac or java command using Ubuntu shell it says those commands are not found? 但是,当我使用Ubuntu shell运行javac或java命令时,它说找不到这些命令吗? So it lists some options that I can enter and one of those is 所以它列出了一些我可以输入的选项,其中之一是

sudo apt install openjdk-8-jdk-headless

But when I run this command it says: 但是,当我运行此命令时,它说:

E: Unable to locate package openjdk-8-jdk-headless

I don't get it. 我不明白 I already have Java-8 installed and the PATH variables set, it works fine for the windows command prompt but fails to work with ubuntu. 我已经安装了Java-8,并设置了PATH变量,它在Windows命令提示符下工作正常,但无法在ubuntu上使用。 What am I doing wrong? 我究竟做错了什么?

Thanks. 谢谢。

Do you have to use the OpenJDK version? 您必须使用OpenJDK版本吗? Try this 尝试这个

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer

See this link and this issue 看到这个链接这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM