安装正确的 Java 后,MacOS 上的 Oracle SQLDeveloper 无法打开

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/50708608/
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-10 23:46:19  来源:igfitidea点击:

Oracle SQLDeveloper on MacOS won't open after installation of correct Java

javaoraclemacosjava-8oracle-sqldeveloper

提问by R.L

I downloaded the Oracle SQLDeveloper, but when I opened it, it said that it requires a minimum of Java 8 and gave me the website for the download. I went on and downloaded Java 10.0.1, but when I went back on to open SQL, it continued saying it required a minimum of Java 8.

我下载了 Oracle SQLDeveloper,但是当我打开它时,它说它至少需要 Java 8 并给了我下载的网站。我继续下载了 Java 10.0.1,但是当我继续打开 SQL 时,它继续说它至少需要 Java 8。

I checked that the Java 10.0.1 had installed correctly, and I'm pretty sure it has. It shows up in System Preferences and when clicked, it opens the Java Control Panel fine.

我检查了 Java 10.0.1 是否已正确安装,我很确定它已经安装了。它显示在“系统偏好设置”中,单击时会很好地打开 Java 控制面板。

I had also found someone recommending trying this command:

我还发现有人推荐尝试这个命令:

c:\Program Files\Oracle\sqlcl.3\sqlcl\bin>java -version

After trying this in the Terminal, I ended up with command not found.

在终端中尝试了这个之后,我最终得到了command not found.

I'm on a MacOS X El Captain 10.11.6.

我在 MacOS X El Captain 10.11.6 上。

回答by ewramner

If you check the download page (http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html) it says JDK8 required. I don't think it supports Java 9 or 10. Many programs still don't.

如果您查看下载页面(http://www.oracle.com/technetwork/developer-tools/sql-developer/downloads/index.html),它会显示需要 JDK8。我认为它不支持 Java 9 或 10。许多程序仍然不支持。

As for the command you tried it is for Windows, there is no c:\Program Files on MacOS. It should be enough to run java -version.

至于您尝试的命令是针对 Windows 的,MacOS 上没有 c:\Program Files。跑起来应该就够了java -version

You may want to check how you can run multiple Java versions, see Mac OS X and multiple Java versions. It is a bit messy, but sooner or later you will need it!

您可能想要检查如何运行多个 Java 版本,请参阅Mac OS X 和多个 Java 版本。它有点乱,但迟早你会需要它!

回答by Kris Rice

SQL Developer runs this which checks for java 9 then 8. We don't yet support (lack of a ton of testing) java 10. You went to new for us. Back up to 8 or 9 and should be fine.

SQL Developer 运行它来检查 java 9 然后是 8。我们还不支持(缺乏大量测试)java 10。你为我们去了新的。备份到 8 或 9 应该没问题。

We use /usr/libexec/java_homewhich allows us to specify which version of java we'd like to run. So even if you have N javas installed, it should return the highest one that was passed in with flags.

我们使用/usr/libexec/java_homewhich 允许我们指定我们想要运行的 Java 版本。因此,即使您安装了 N 个 java,它也应该返回带标志传入的最高一个。

   #!/bin/bash 
              ##### THIS IS CHECKING FOR JAVA 9 #####
   TMP_PATH=`/usr/libexec/java_home -F -v 9`

   if [ -z "$TMP_PATH" ] ; then

              ##### THIS IS CHECKING FOR JAVA 8 #####
     TMP_PATH=`/usr/libexec/java_home -F -v 1.8`

     if [ -z "$TMP_PATH" ] ; then
       osascript -e 'tell app "System Events" to display dialog "SQL Developer requires a     minimum of Java 8. \nJava 8 can be downloaded from:\n http://www.oracle.com/technetwork    /java/javase/downloads/"'
       exit 1
     fi
   fi

回答by Adam

The post above is right: SQLDeveloper only runs under Java 8.

上面的帖子是对的:SQLDeveloper 只在 Java 8 下运行

This is counter-intuitive as other programs runs under at leastX version of a software (not only X version). I kept downloading Java 11 with no luck.

这是违反直觉的,因为其他程序至少在软件的X 版本不仅是 X 版本)下运行。我一直在下载 Java 11,但没有运气。

After 1 failed attempt a month ago and two hours of searching today, I found this easy fix worked for me.

经过一个月前的 1 次失败尝试和今天的两个小时搜索,我发现这个简单的修复对我有用

Solution

解决方案

  1. Delete the following Java files and folders on your mac.

    • /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
    • /Library/Java/JavaVirtualMachines/(delete current java folder)
  2. Download and install Java 8. https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  3. Launch SQLDeveloper.

  1. 删除 Mac 上的以下 Java 文件和文件夹。

    • /Library/Internet Plug-Ins/JavaAppletPlugin.plugin
    • /Library/Java/JavaVirtualMachines/(删除当前java文件夹)
  2. 下载并安装 Java 8。 https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html

  3. 启动 SQLDeveloper。

回答by Aphoid

If OpenJDKwould work for you, and you are already using/willing to use Homebrew, AdoptOpenJDKworks for me:

如果OpenJDK对你有用,并且你已经在使用/愿意使用HomebrewAdoptOpenJDK对我有用

brew tap AdoptOpenJDK/openjdk
brew install adoptopenjdk8

I have not tested this thoroughly, but at the very least I am able to bring up SQL Developer 19.1.0.094, connect to a database, and run queries on it.

我没有对此进行彻底的测试,但至少我能够启动 SQL Developer 19.1.0.094,连接到数据库,并在其上运行查询。

It did not work if I tried to use their instructions to install the "latest" version: brew cask install adoptopenjdk, as this seems to install OpenJDK 12.x as of May 2019.

如果我尝试使用他们的说明安装“最新”版本brew cask install adoptopenjdk,则它不起作用:,因为截至 2019 年 5 月,这似乎安装了 OpenJDK 12.x。

There are other methods to install OpenJDK, but this was an easy one.

还有其他安装 OpenJDK 的方法,但这是一个简单的方法。

回答by Johan

I had the same problem, and none of the above solutions worked for me. I am running MacOS 10.14.5

我遇到了同样的问题,上述解决方案都不适合我。我正在运行 MacOS 10.14.5

Instead, I had to uninstall Java12 which I had installed via home brew, and sqlDeveloper. After uninstalling and deleting both, I installed Java8 JDK directly from the oracle website via download, and then I reinstalled sqlDeveloper. After wasting three hours trying to get this to work, this set of steps finally did the trick. I hope this helps others.

相反,我不得不卸载我通过 Home brew 和 sqlDeveloper 安装的 Java12。卸载和删除后,我直接从oracle网站下载安装了Java8 JDK,然后我重新安装了sqlDeveloper。在浪费了三个小时试图让它工作之后,这组步骤终于成功了。我希望这对其他人有帮助。

回答by user12221647

You have to set the Java home. Please follow the steps given below.

您必须设置 Java 主页。请按照以下步骤操作。

  • find the installation directory by right-clicking the OracledataModeler icon and "Show Package Content" this will show you the installation directory on a Mac

  • Go to the (installation directoy for example ) /Users/user directory/Downloads/OracleDataModeler.app/Contents/Resources/datamodeler/datamodeler/bin

  • edit the datamodeler.conf file in the \datamodeler\datamodeler\bin directoryand add SetJavaHome. (e.g. SetJavaHome /usr/lib/jdk18)

  • SetJavaHome /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home

  • Start the SQL data modeler from (installation directory) /Users/user directory/Downloads/OracleDataModeler.app/Contents/Resources/datamodeler/datamodeler.sh

  • 通过右键单击 OracledataModeler 图标和“显示包内容”找到安装目录,这将显示 Mac 上的安装目录

  • 转到(例如安装目录) /Users/user directory/Downloads/OracleDataModeler.app/Contents/Resources/datamodeler/datamodeler/bin

  • 编辑\datamodeler\datamodeler\bin directorydatamodeler.conf文件并添加 SetJavaHome。(例如 SetJavaHome /usr/lib/jdk18

  • 设置JavaHome /Library/Java/JavaVirtualMachines/jdk1.8.0_221.jdk/Contents/Home

  • 从(安装目录)启动 SQL 数据建模器 /Users/user directory/Downloads/OracleDataModeler.app/Contents/Resources/datamodeler/datamodeler.sh

回答by Sireesh Yarlagadda

After unzipping the mac sqldeveloper.zip file, you will find the SQLDeveloper.app file.

解压 mac sqldeveloper.zip 文件后,您将找到 SQLDeveloper.app 文件。

Copy the SQLDeveloper.app to Applications folder. Later execute the below command in terminal.

将 SQLDeveloper.app 复制到 Applications 文件夹。稍后在终端中执行以下命令。

xattr -d com.apple.quarantine /Applications/SQLDeveloper.app