NetBeans Forums

 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
  

Maven apps: runtime Java version being ignored

 
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users
View previous topic :: View next topic  
Author Message
Stephen Winnall
Posted via mailing list.





PostPosted: Wed Jan 27, 2010 11:49 am    Post subject: Maven apps: runtime Java version being ignored Reply with quote

It seems that the runtime Java version of applications built with
Maven in NetBeans is always the same as the version of the JVM that
NetBeans runs in. Shouldn't it be the version defined in the
properties of the project?

An example - the following class belongs to a project created with the
Maven Quickstart Archetype:

public class App
{
public static void main( String[] args )
{
System.out.println( "java.version:
"+System.getProperty("java.version") );
}
}

I'm running NetBeans 6.8 under Mac OS X 10.5.8 and Java 1.6.0_17. I
set the Java version in the project properties to 1.5. The following
extract from the POM confirms this:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>${project.build.sourceEncoding}</
encoding>
</configuration>
</plugin>

When I run the project, the following text is printed:

java.version: 1.6.0_17

Shouldn't it be running under 1.5 and therefore print

java.version: 1.5.0_22

or have I misunderstood something?

I guess the app is being run by the Maven goal exec:java, which
explicitly uses the JVM that Maven is running in, and I assume that
Maven is using the same version as the IDE.

Steve




--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
Back to top
mkleint
Posted via mailing list.





PostPosted: Wed Jan 27, 2010 11:49 am    Post subject: Maven apps: runtime Java version being ignored Reply with quote

setting source/target level simply tells what version of jdk is to be
used for compilation. Maven in general has (let's say) suboptimal ways
of defining the JDK with which to compile. The most common approach is
to start the build itself with the given JDK. That's what we do in the
IDE as well, when you set it in the project customizer panel.

Milos

Stephen Winnall wrote:
Quote:
It seems that the runtime Java version of applications built with
Maven in NetBeans is always the same as the version of the JVM that
NetBeans runs in. Shouldn't it be the version defined in the
properties of the project?

An example - the following class belongs to a project created with the
Maven Quickstart Archetype:

public class App
{
public static void main( String[] args )
{
System.out.println( "java.version:
"+System.getProperty("java.version") );
}
}

I'm running NetBeans 6.8 under Mac OS X 10.5.8 and Java 1.6.0_17. I
set the Java version in the project properties to 1.5. The following
extract from the POM confirms this:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.5</source>
<target>1.5</target>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>

When I run the project, the following text is printed:

java.version: 1.6.0_17

Shouldn't it be running under 1.5 and therefore print

java.version: 1.5.0_22

or have I misunderstood something?

I guess the app is being run by the Maven goal exec:java, which
explicitly uses the JVM that Maven is running in, and I assume that
Maven is using the same version as the IDE.

Steve



Back to top
Display posts from previous:   
Post new topic   Reply to topic    NetBeans Forums -> NetBeans Users All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB
By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo