简体   繁体   English

Android Studios的桌面启动器找不到JDK,但相同的studio.sh脚本可在终端中运行吗?

[英]Desktop launcher for Android Studios can't find JDK but same studio.sh script works in terminal?

I can run my studio.sh script to start Android Studios from the command line just fine. 我可以运行studio.sh脚本从命令行启动Android Studio。 If I use my desktop launcher it says it can't find the JDK! 如果我使用桌面启动器,它会说找不到JDK! I recently created a .desktop to add in my applications folder to be able to just click on a desktop icon to run this script using: 我最近创建了一个.desktop,以添加到我的应用程序文件夹中,只需单击一个桌面图标即可使用以下命令运行此脚本:

[Desktop Entry]
Type=Application
Terminal=true
Name=unmount-mount
Icon=/path/to/icon/icon.svg
Exec=/path/to/file/mount-unmount.sh

When I use this new icon with the correct paths added in, I get a No JDK Found error. 当我使用此新图标并添加正确的路径时,出现No JDK Found错误。 If I go back to manually running studio.sh from the command line, it starts up just fine. 如果我从命令行返回手动运行studio.sh,它会正常启动。 I know the script is running because the error comes directly from it. 我知道脚本正在运行,因为错误直接来自此脚本。 Is a path different because the launcher is running it? 因为启动程序正在运行,所以路径是否不同? This doesn't make sense. 这没有道理。 I have checked permissions as well and everything should be fine. 我还检查了权限,一切都应该很好。

I know this answer comes late for the question. 我知道这个问题来晚了。 Thing is I have this same issue today 29/9/2015 and I managed to fix it. 问题是,今天29/9/2015我也遇到了同样的问题,我设法解决了这个问题。

The problem is in the Exec property. 问题出在Exec属性中。 The command will try to find a value for JAVA_HOME or a variable holding your JDK location. 该命令将尝试查找JAVA_HOME的值或保存您的JDK位置的变量。

The fix is to add the following: 解决方法是添加以下内容:

Exec=bash -i /path/to/your/studio.sh

So this will execute your .bashrc file first, which will initialize the JDK or JAVA_HOME vars. 因此,这将首先执行您的.bashrc文件,该文件将初始化JDK或JAVA_HOME vars。

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

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