在cmd中运行“ mvn -v”时未显示“ Java Home”

时间:2019-05-03 00:34:49

标签: java maven

在命令提示符下运行“ mvn -v”时,最初出现一个错误,说Java Home设置为JRE而不是JDK。我已经确保从oracle的网站(而不是JRE)安装了JDK 12。经过几次尝试,在将JAVA_HOME添加为用户变量后,该错误消失了(该错误早已在System变量中添加了)。

但是在命令提示符下运行“ mvn -v”时,我现在根本看不到“ Java Home”。我的结果如下所示:

C:\ Users \ uzmaf> mvn -v Apache Maven 3.6.1(d66c9c0b3152b2e69ee9bac180bb8fcc8e6af555; 2019-04-04T14:00:29-05:00) Maven主页:C:\ Program Files \ apache-maven-3.6.1-bin \ apache-maven-3.6.1 \ bin .. Java版本:12.0.1,供应商:Oracle Corporation,运行时:C:\ Program Files \ Java \ jdk-12.0.1 默认语言环境:en_US,平台编码:Cp1252 操作系统名称:“ windows 10”,版本:“ 10.0”,拱门:“ amd64”,家族:“ windows”

我在这里想念什么?

1 个答案:

答案 0 :(得分:0)

在Maven 3.6.1版中,他们已从版本命令的显示中删除了“ JAVA HOME”属性,但这不会造成任何问题。您可以在以下链接中引用CLIReportingUtils.showVersion()方法:

https://github.com/apache/maven/blob/maven-3.6.1/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java

public static String showVersion()
{
    final String ls = System.getProperty( "line.separator" );
    Properties properties = getBuildProperties();
    StringBuilder version = new StringBuilder( 256 );
    version.append( buffer().strong( createMavenVersionString( properties ) ) ).append( ls );
    version.append( reduce(
        properties.getProperty( "distributionShortName" ) + " home: " + System.getProperty( "maven.home",
                                                                                            "<unknown Maven "
                                                                                                + "home>" ) ) )
        .append( ls );
    version.append( "Java version: " ).append(
        System.getProperty( "java.version", "<unknown Java version>" ) ).append( ", vendor: " ).append(
        System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( ", runtime: " ).append(
        System.getProperty( "java.home", "<unknown runtime>" ) ).append( ls );
    version.append( "Default locale: " ).append( Locale.getDefault() ).append( ", platform encoding: " ).append(
        System.getProperty( "file.encoding", "<unknown encoding>" ) ).append( ls );
    version.append( "OS name: \"" ).append( Os.OS_NAME ).append( "\", version: \"" ).append( Os.OS_VERSION ).append(
        "\", arch: \"" ).append( Os.OS_ARCH ).append( "\", family: \"" ).append( Os.OS_FAMILY ).append( '\"' );
    return version.toString();
}