安装后在 Linux 中哪里可以找到 Java SDK?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5251323/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-04 00:29:07  来源:igfitidea点击:

Where can I find the Java SDK in Linux after installing it?

linuxjava

提问by dinesh707

I installed JDK using apt-get install but I don't know where my jdk folder is. I need to set the path for that. Does any one have a clue on the location?

我使用 apt-get install 安装了 JDK,但我不知道我的 jdk 文件夹在哪里。我需要为此设置路径。有没有人知道地点的线索?

采纳答案by Pa?lo Ebermann

This depends a bit from your package system ... if the javacommand works, you can type readlink -f $(which java)to find the location of the java command. On the OpenSUSE system I'm on now it returns /usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java(but this is not a system which uses apt-get).

这在一定程度上取决于您的软件包系统……如果该java命令有效,您可以键入readlink -f $(which java)以查找 java 命令的位置。在我现在使用的 OpenSUSE 系统上,它返回/usr/lib64/jvm/java-1.6.0-openjdk-1.6.0/jre/bin/java(但这不是一个使用 的系统apt-get)。



On Ubuntu, it looks like it is in/usr/lib/jvm/java-6-openjdk/for OpenJDK, and in some other subdirectory of /usr/lib/jvm/for Suns JDK (and other implementations as well, I think).

在 Ubuntu 上,它看起来像是在/usr/lib/jvm/java-6-openjdk/OpenJDK 中,在/usr/lib/jvm/Suns JDK 的其他一些子目录中(我认为还有其他实现)。

Debian is the same.

Debian 也是一样。



For any given package you can determine what files it installs and where it installs them by querying dpkg. For example for the package 'openjdk-6-jdk': dpkg -L openjdk-6-jdk

对于任何给定的包,您可以通过查询 dpkg 来确定它安装的文件以及安装它们的位置。例如对于包“openjdk-6-jdk”:dpkg -L openjdk-6-jdk

回答by Brent Worden

Use find to located it. It should be under /usrsomewhere:

使用 find 来定位它。它应该在/usr某个地方:

find /usr -name java

When running the command, if there are too many "Permission denied" message obfuscating the actual found results then, simply redirect stderr to /dev/null

运行命令时,如果有太多“权限被拒绝”消息混淆了实际找到的结果,只需将 stderr 重定向到 /dev/null

find /usr -name java 2> /dev/null

回答by The Surrican

$ which java 

should give you something like

应该给你类似的东西

/usr/bin/java

回答by Andrew T Finnell

This question will get moved but you can do the following

这个问题会被移动,但你可以做以下事情

which javac

or

或者

cd /
find . -name 'javac'

回答by forcefsck

update-java-alternatives -l

will tell you which java implementation is the default for your system and where in the filesystem it is installed. Check the manual for more options.

会告诉你哪个 java 实现是你的系统的默认实现以及它安装在文件系统的哪个位置。查看手册以获取更多选项。

回答by Dutch Glory

on OpenSUSE 13.1/13.2 its: /usr/lib64/jvm/java-1.6.0-openjdk-(version-number)
version-number can be 1.7.x 1.8.x etc. check software manager witch version you have installed...

在 OpenSUSE 13.1/13.2 上,它的:/usr/lib64/jvm/java-1.6.0-openjdk-(version-number)
版本号可以是 1.7.x 1.8.x 等。检查您安装的软件管理器版本...

André

安德烈

回答by iankits

Another best way to find Java folder path is to use alternativescommand in Fedora Linux (I know its for Ubuntu but I hit this post from google just by its headline). Just want to share incase people like me looking for answers for fedora flavour.

查找 Java 文件夹路径的另一种最佳方法是alternatives在 Fedora Linux 中使用命令(我知道它适用于 Ubuntu,但我只是通过标题从 google 找到了这篇文章)。只是想分享一下,以防像我这样的人正在寻找软呢帽风味的答案。

To display all information regarding java

显示有关java的所有信息

alternatives --display java

回答by Ashansu Pant

Simple, try it:

很简单,试试看:

It's /usr/local/java/jdk[version]

它是/ usr/local/java/jdk[版本]

回答by Hasan

the command: sudo update-alternatives --config javawill find the complete path of all installed Java versions

命令:sudo update-alternatives --config java将找到所有已安装 Java 版本的完整路径

回答by Anubhav Gupta

Three Step Process: First: open Terminal->$ whereis javait would give output like this: java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

三步过程:首先:打开终端->$ whereis java它会给出这样的输出: java: /usr/bin/java /usr/share/java /usr/share/man/man1/java.1.gz

Second: ls -l /usr/bin/javaIt would give output like this: lrwxrwxrwx 1 root root 22 Feb 9 10:59 /usr/bin/java -> /etc/alternatives/java

第二: ls -l /usr/bin/java它会给出这样的输出: lrwxrwxrwx 1 root root 22 Feb 9 10:59 /usr/bin/java -> /etc/alternatives/java

Third: ls -l /etc/alternatives/javaoutput is the JDK path: lrwxrwxrwx 1 root root 46 Feb 9 10:59 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java

第三: ls -l /etc/alternatives/java输出是JDK路径: lrwxrwxrwx 1 root root 46 Feb 9 10:59 /etc/alternatives/java -> /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java