You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@netbeans.apache.org by gi...@libero.it.INVALID on 2019/01/22 10:34:55 UTC

java home configuration in maven

Hi, I have a problem with the java home configuration when I work with Netbeans 10 (but I guess that also other versions are affected).

- In my company we still use JDK 8 so I configured the JAVA_HOME system variable to point to the JDK 8 folder. This configuration seems correct, I can see from the prompt that typing java -version the correct version of java is taken in account.

- NetBeans 10 "requires" (prefers) Java 11 so I downloaded the OpenJDK11, extracted it on a folder and configured the path on the netbeans.conf file (netbeans_jdkhome="D:\java\jdk11") also this configuration seems to be ok.

- One of the maven project on which I'm working (remind we use java 8) has an external dependency like this:
          <dependency>
                <groupId>com.sun</groupId>
                <artifactId>tools</artifactId>
                <version>${jdk.version}</version>
                <scope>system</scope>
                <systemPath>${java.home}/../lib/tools.jar</systemPath>
            </dependency>

  The problem is that ${java.home} is translated using the netbeans_jdkhome path and not the system JAVA_HOME variable so it points to jdk 11 and not jdk 8 and it doesn't find the path. 


In Netbeans Java Platform Manager I have both the java version jdk 8 and jdk 11(default) but the default version can't be changed.

How can I workaround this limitation so that I can work on the maven project using the jdk 8 home?

Kind regards,

Re: java home configuration in maven

Posted by Emilian Bold <em...@gmail.com>.
In Project Properties | Build | Compile you can configure the 'Java
Platform' for the project. I see that switching to Java 8 makes the
compilation work for me:

cd /Users/apache/CoolBeansProjects/deleletmeee;
JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_181.jdk/Contents/Home
"/Users/apache/work/coolbeans/CoolBeans-2018.12-20190110-235217/CoolBeans/CoolBeans
2018.12.app/Contents/Resources/coolbeans/java/maven/bin/mvn" clean
install

    <dependencies>
        <dependency>
            <groupId>com.sun</groupId>
            <artifactId>tools</artifactId>
            <version>1.8</version>
            <scope>system</scope>
            <systemPath>${java.home}/../lib/tools.jar</systemPath>
        </dependency>
    </dependencies>

OTOH, using the default Java 10 breaks the build:

cd /Users/apache/CoolBeansProjects/deleletmeee;
"JAVA_HOME=/Users/apache/work/coolbeans/CoolBeans-2018.12-20190110-235217/CoolBeans/CoolBeans
2018.12.app/Contents/Resources/coolbeans/jre"
"/Users/apache/work/coolbeans/CoolBeans-2018.12-20190110-235217/CoolBeans/CoolBeans
2018.12.app/Contents/Resources/coolbeans/java/maven/bin/mvn" clean
install

Failed to execute goal on project deleletmeee: Could not resolve
dependencies for project com.mycompany:deleletmeee:jar:1.0-SNAPSHOT:
Could not find artifact com.sun:tools:jar:1.8 at specified path
/Users/apache/work/coolbeans/CoolBeans-2018.12-20190110-235217/CoolBeans/CoolBeans
2018.12.app/Contents/Resources/coolbeans/jre/../lib/tools.jar -> [Help
1]

So the only remaining issue is that, indeed, you cannot globally
change the default Java Platform from Tools | Java Platforms.

--emi

http://coolbeans.xyz/ - CoolBeans: An IDE for Java, JavaEE, PHP and more!

On Tue, Jan 22, 2019 at 12:37 PM Geertjan Wielenga
<ge...@googlemail.com.invalid> wrote:
>>
>> - NetBeans 10 "requires" (prefers) Java 11
>
>
> No, it does not. It runs on JDK 8 or above, to the current JDK, which is JDK 11.
>
> Gj
>
> On Tue, Jan 22, 2019 at 11:35 AM <gi...@libero.it.invalid> wrote:
>>
>> Hi, I have a problem with the java home configuration when I work with Netbeans 10 (but I guess that also other versions are affected).
>>
>> - In my company we still use JDK 8 so I configured the JAVA_HOME system variable to point to the JDK 8 folder. This configuration seems correct, I can see from the prompt that typing java -version the correct version of java is taken in account.
>>
>> - NetBeans 10 "requires" (prefers) Java 11 so I downloaded the OpenJDK11, extracted it on a folder and configured the path on the netbeans.conf file (netbeans_jdkhome="D:\java\jdk11") also this configuration seems to be ok.
>>
>> - One of the maven project on which I'm working (remind we use java 8) has an external dependency like this:
>>           <dependency>
>>                 <groupId>com.sun</groupId>
>>                 <artifactId>tools</artifactId>
>>                 <version>${jdk.version}</version>
>>                 <scope>system</scope>
>>                 <systemPath>${java.home}/../lib/tools.jar</systemPath>
>>             </dependency>
>>
>>   The problem is that ${java.home} is translated using the netbeans_jdkhome path and not the system JAVA_HOME variable so it points to jdk 11 and not jdk 8 and it doesn't find the path.
>>
>>
>> In Netbeans Java Platform Manager I have both the java version jdk 8 and jdk 11(default) but the default version can't be changed.
>>
>> How can I workaround this limitation so that I can work on the maven project using the jdk 8 home?
>>
>> Kind regards,

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@netbeans.apache.org
For additional commands, e-mail: users-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists


Re: java home configuration in maven

Posted by Geertjan Wielenga <ge...@googlemail.com.INVALID>.
>
> - NetBeans 10 "requires" (prefers) Java 11
>

No, it does not. It runs on JDK 8 or above, to the current JDK, which is
JDK 11.

Gj

On Tue, Jan 22, 2019 at 11:35 AM <gi...@libero.it.invalid> wrote:

> Hi, I have a problem with the java home configuration when I work with
> Netbeans 10 (but I guess that also other versions are affected).
>
> - In my company we still use JDK 8 so I configured the JAVA_HOME system
> variable to point to the JDK 8 folder. This configuration seems correct, I
> can see from the prompt that typing java -version the correct version of
> java is taken in account.
>
> - NetBeans 10 "requires" (prefers) Java 11 so I downloaded the OpenJDK11,
> extracted it on a folder and configured the path on the netbeans.conf file
> (netbeans_jdkhome="D:\java\jdk11") also this configuration seems to be ok.
>
> - One of the maven project on which I'm working (remind we use java 8) has
> an external dependency like this:
>           <dependency>
>                 <groupId>com.sun</groupId>
>                 <artifactId>tools</artifactId>
>                 <version>${jdk.version}</version>
>                 <scope>system</scope>
>                 <systemPath>${java.home}/../lib/tools.jar</systemPath>
>             </dependency>
>
>   The problem is that ${java.home} is translated using the
> netbeans_jdkhome path and not the system JAVA_HOME variable so it points to
> jdk 11 and not jdk 8 and it doesn't find the path.
>
>
> In Netbeans Java Platform Manager I have both the java version jdk 8 and
> jdk 11(default) but the default version can't be changed.
>
> How can I workaround this limitation so that I can work on the maven
> project using the jdk 8 home?
>
> Kind regards,
>