This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 250430

Summary: NetBeans should properly support cross-compiling
Product: java Reporter: terje7601
Component: CompilerAssignee: Dusan Balek <dbalek>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: 8.0.2   
Hardware: PC   
OS: Other   
Issue Type: DEFECT Exception Reporter:

Description terje7601 2015-02-15 08:37:38 UTC
In the Project Properties:
under Sources you have "Source/Binary Format"
under Libraries you have "Java Platform"

In my case, there is only 1 Java Platform, JDK 1.8. Now suppose I set the "Source/Binary Format" to Java 7 (i.e. "JDK 7" (Ant) or "1.7" (Maven)). The problem now is that Java 8 language constructs (like lambda expressions) are marked as errors, but usage of Java 8 APIs isn't. In my opinion, if one sets the "Source/Binary Format" to Java 7, it means they intend to run the program on JRE 7. So usage of Java 8 APIs should be marked as errors as well (and such classes should be excluded from auto-completion etc.).

NetBeans ought to give a warning and tell the user to add a "JDK 1.7" Java Platform. For Java 7, NetBeans could just provide a link to the "Server JRE" downloads (since it's a simple zip, I personally prefer this over a JDK installation).

The real problem here, is that NetBeans should cross-compile by using the javac "bootclasspath" and "extdirs" options. These options should point to a JDK installation that matches the "target" option. From http://docs.oracle.com/javase/8/docs/technotes/tools/windows/javac.html : "It is important to use the -bootclasspath and -extdirs options when cross-compiling."