IDEA jdk,maven 配置问题出在哪?

发布于 2022-09-12 02:52:57 字数 2952 浏览 40 评论 0

发现问题:如下两个配置jdk路径文件区别?
sudo gedit ~/.bashrc
/etc/profile

jdk实际路径是:/usr/local/jdk1.8/jdk1.8.0_161/bin/java
idea报错路径是(在下面):Cannot run program "/usr/local/jdk1.8/bin/java

这肯定找不到啊!
应该在哪里改?

我将 /etc/profile 下的路径改为如下,还是不行。

#set Java environment
export JAVA_HOME=/usr/local/jdk1.8/jdk1.8.0_161/bin/java
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH

==================================================

1).首先是idea导入maven项目失败提示:Unable to import Maven projectCaused by:部分日志如下(jdk路径不对?):

Caused by: java.rmi.RemoteException: Cannot start maven service; nested exception is: 
    com.intellij.execution.ExecutionException: Cannot run program "/usr/local/jdk1.8/bin/java" (in directory "/usr/local/src/idea/idea-IU-192.5728.98/bin"): error=2, No such file or directory
    at org.jetbrains.idea.maven.server.MavenServerManager.create(MavenServerManager.java:238)
    
    Caused by: com.intellij.execution.ExecutionException: Cannot run program "/usr/local/jdk1.8/bin/java" (in directory "/usr/local/src/idea/idea-IU-192.5728.98/bin"): error=2, No such file or directory
    at com.intellij.execution.rmi.RemoteProcessSupport.acquire(RemoteProcessSupport.java:143)

Caused by: com.intellij.execution.process.ProcessNotCreatedException: Cannot run program "/usr/local/jdk1.8/bin/java" (in directory "/usr/local/src/idea/idea-IU-192.5728.98/bin"): error=2, No such file or directory
    at com.intellij.execution.configurations.GeneralCommandLine.createProcess(GeneralCommandLine.java:412)
    
    Caused by: java.io.IOException: Cannot run program "/usr/local/jdk1.8/bin/java" (in directory "/usr/local/src/idea/idea-IU-192.5728.98/bin"): error=2, No such file or directory
    at java.base/java.lang.ProcessBuilder.start(ProcessBuilder.java:1128)
    
    Caused by: java.io.IOException: error=2, No such file or directory
    
    Caused by: java.rmi.RemoteException: Cannot start maven service; nested exception is: 
    com.intellij.execution.ExecutionException: Cannot run program "/usr/local/jdk1.8/bin/java" (in directory "/usr/local/src/idea/idea-IU-192.5728.98/bin"): error=2, No such file or directory
    

2). java -version信息如下:

weibo@a119966332211:~$ java -version
java version "1.8.0_161"
Java(TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.161-b12, mixed mode)

3). sudo gedit /etc/profile 配置如下:

#set Java environment
export JAVA_HOME=/usr/local/jdk1.8/jdk1.8.0_161
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=.:${JAVA_HOME}/bin:$PATH

export MAVEN_HOME=/opt/maven/apache-maven-3.6.3
export M2=$MAVEN_HOME/bin    
export PATH=$M2:$PATH

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文