Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
496 views
in Technique[技术] by (71.8m points)

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

发现问题:如下两个配置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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...