简体   繁体   English

Windows和Linux之间的Intellij项目-使用“提供的默认系统” JDK?

[英]Intellij project between Windows and Linux - use the 'default system provided' JDK?

I've got two dev workstations, one running Windows, the other running Linux. 我有两个开发工作站,一个运行Windows,另一个运行Linux。 I work on a Java project using Intellij on both. 我同时使用Intellij进行Java项目。 Both platforms have the Oracle JDK 7 installed in the default locations. 这两个平台均在默认位置安装了Oracle JDK 7。

For some annoying reason, every time I switch platforms, I need to update the project configuration to specify what JDK it should be using. 由于某些令人讨厌的原因,每次切换平台时,我都需要更新项目配置以指定应使用的JDK。 In the project's "Project SDK" setting, there's a JDK selection which includes two entries - 1 for a JDK in c:\\Program Files\\Java\\jdk_1.7 and the other for a JDK in /usr/lib/jvm/java-7-jdk/ . 在项目的“ Project SDK”设置中,有一个JDK选择,其中包括两个条目-1个条目用于c:\\Program Files\\Java\\jdk_1.7中的JDK,另一个c:\\Program Files\\Java\\jdk_1.7用于/usr/lib/jvm/java-7-jdk/的JDK。 /usr/lib/jvm/java-7-jdk/ If I open the project on Linux, I have to specifically set the Project JDK to be the second. 如果在Linux上打开项目,则必须将Project JDK专门设置为第二个。 If I save the project, close, commit, and then checkout and open on Windows, it complains it can't find the JDK, and I have to manually set it to the Windows version. 如果我保存该项目,然后在Windows上关闭,提交,然后检出然后打开,它会抱怨找不到JDK,因此必须手动将其设置为Windows版本。

Why can't Intellij figure this out automatically? 为什么Intellij不能自动解决这个问题? I appreciate that testing against multiple installed JDKs is a useful feature, but is there a way to tell a project to 'just use the default JDK'? 我赞赏针对多个已安装的JDK进行测试是一项有用的功能,但是有没有办法告诉项目“仅使用默认JDK”?

You need to have your JDK configurations to have the same name, lile 1.6 or 1.7 . 您需要使JDK配置具有相同的名称,lile 1.61.7 Project file references JDK by its name only so it will work out of the box in all IDEA installations on different operation systems, the only requirement is that there is JSDK defined under exactly the same name. 项目文件仅按名称引用JDK,因此它将在不同操作系统上的所有IDEA安装中开箱即用,唯一的要求是使用完全相同的名称定义JSDK。

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

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