为什么我不能在ubuntu中使用这些命令运行java?

时间:2021-12-25 08:06:30

I just entered command like this.

我刚刚输入了这样的命令。

stillily@ubuntu:~$ cd Desktop/
stillily@ubuntu:~/Desktop$ cd jdk1.8.0_51/
stillily@ubuntu:~/Desktop/jdk1.8.0_51$ cd bin/
stillily@ubuntu:~/Desktop/jdk1.8.0_51/bin$ ls
appletviewer  jar        javadoc         javapackager  jconsole  jhat  jmc         jsadebugd  jvisualvm     pack200     rmiregistry  tnameserv  xjc
ControlPanel  jarsigner  javafxpackager  java-rmi.cgi  jcontrol  jinfo  jmc.ini     jstack     keytool       policytool  schemagen    unpack200
extcheck      java       javah           javaws        jdb       jjs    jps         jstat      native2ascii  rmic        serialver    wsgen
idlj          javac      javap           jcmd          jdeps     jmap   jrunscript  jstatd     orbd          rmid        servertool   wsimport
stillily@ubuntu:~/Desktop/jdk1.8.0_51/bin$ java
The program 'java' can be found in the following packages:

And it confused me a lot that just this morning I can run java correctly.

它让我很困惑,就在今天早上我可以正确运行java。

1 个解决方案

#1


1  

You are trying to use a downloaded version of Java, not a system wide install. This means you need to prefix the command with a path:

您正在尝试使用下载的Java版本,而不是系统范围的安装。这意味着您需要在命令前添加路径:

$ ./java # when you're in the bin directory
$ ~/Desktop/jdk1.8.0_51/bin/java # from anywhere else

I would recommend just installing OpenJDK with apt-get though.

我建议只使用apt-get安装OpenJDK。

#1


1  

You are trying to use a downloaded version of Java, not a system wide install. This means you need to prefix the command with a path:

您正在尝试使用下载的Java版本,而不是系统范围的安装。这意味着您需要在命令前添加路径:

$ ./java # when you're in the bin directory
$ ~/Desktop/jdk1.8.0_51/bin/java # from anywhere else

I would recommend just installing OpenJDK with apt-get though.

我建议只使用apt-get安装OpenJDK。