NetBeans IDE Java 1.4 compatibility: compiler not warning on JDK 5+ classes/methods - netbeans

When NetBeans 7 (or NetBeans 3.6) is compiling with -source 1.4 enabled, why doesn't it warn when compiling with methods (or classes) introduced #since 1.5 or #since 1.6?

The javac docs imply that the -source option is about language features, not library features.
-source release
Specifies the version of source code accepted. The following values for release are allowed:
1.3 The compiler does not support assertions, generics, or other
language features introduced after JDK
1.3.
1.4 The compiler accepts code containing assertions, which were
introduced in JDK 1.4.
1.5 The compiler accepts code containing generics and other language
features introduced in JDK 5.
5 Synonym for 1.5.
1.6 This is the default value. No language changes were introduced in
Java SE 6. However, encoding errors in
source files are now reported as
errors, instead of warnings, as
previously.
6 Synonym for 1.6.

Related

Scala not builds on Java 10

while building through Intellij Idea, I got the following message:
Error:scalac: 'jvm-1.10' is not a valid choice for '-target'
Error:scalac: bad option: '-target:jvm-1.10'
later, after a Java upgrade
Build, Execution, Deployment -> Build Tools -> Gradle -> Gradle JVM:
1.8 Build, Execution, Deployment -> Complier -> Scala Complier -> Scala Compile Server -> JDK: 1.8
in build.gradle
compileScala.targetCompatibility = 1.8
ScalaCompileOptions.metaClass.useAnt = false
Nothing helps!
upd:
this helps: in build.gradle
tasks.withType(ScalaCompile) {
scalaCompileOptions.useAnt = false
}
not needed:
compileScala.targetCompatibility = 1.8
ScalaCompileOptions.metaClass.useAnt = false
"Error:scalac: 'jvm-1.10' is not a valid choice for '-target' Error:scalac: bad option: '-target:jvm-1.10'"
In the JDK compatibility notes as mentioned below, it also indicates
that the Java 10 is not fully supporting Scala 2.12.6 JDK 9 & 10
compatibility notes
As you were saying you build this through IntelliJ IDEA, I suspect
you haven't configure your java version (Java 10) or scala version
(2.12.6) inside running configuration project settings.
And also please try out building/compile your application through
commandline in order to check whether you are getting the same error
with that (Otherwise this is just bad configuration in IDEA tht you
need to change)
JDK 9 & 10 compatibility notes (Mentioned in Scala Docs)
JDK 9 & 10 compatibility notes
As of Scala 2.12.6 and 2.11.12, JDK 9 & 10 support is incomplete. Notably, scalac will not enforce the restrictions of the Java Platform Module System, which means that code that typechecks may incur linkage errors at runtime.
JDK 9 & 10 support requires minimum sbt version 1.1.0, or 0.13.17 in the 0.13.x series.
For more information on JDK 9 & 10 compatibility, watch the “Support JDK 9” issue on GitHub.
The same issue can happen with mixed multi-module gradle projects that use java 11 and scala 2.12.10.
In that case, it may help to reconfigure IntelliJ (2019.2) via
Settings > Build, Execution, Deployment > Scala Compiler
by removing the targets defined in Additional compiler options for the affected scala modules.
I stumbled over this issue when having the same problem with Java 11. The reconfiguration comment of Roland Ewald solved the problem. It is important to mention, that this reconfiguration has to be made for all modules of the project (at least for me this was necessary) as well as that IntelliJ sometimes hides parts of the Additional compiler options, so be sure to click on expand even if they seem empty or correct.

unsupported major.minor version in jasperstudio 5.6.x with scriptlet classes

I have created a simple .jar with a class to process a parameter in my Jasper report via scriptlets. I have added the .jar to the build path of the report project.
The .jar has been compiled with JDK 1.7, and the execution enviroment of the Jasper project is set to JRE 1.7, and also the Java Compiler compliance level is 1.7. JAVA_HOME points to jdk 1.7.
Still JasperStudio complains of Unsupported major.minor version 51.0 when trying to access the .jar throught the scriptlet parameter.
Is JasperStudio using jdk 1.6 ?! I think I have ensured it does not by setting all relevant Java properties for the project.
My computer does not even have java 1.6.
There is sth about JasperStudio evidently that still is overriding my jre/jdk choices, but I do not know where/how. Please send me your suggestions on where to look. Thanks a millio
This exception occurs when compiled class version (JDK) does not match with the executing class version (JDK). Jasperserver has a inbuilt JRE within it.
Please confirm the jasperserver JDK Version with the Installed JDK version (Oracle).
To fix the actual problem you should try to either run the Java code with a newer version of Java JRE or specify the target parameter to the Java compiler to instruct the compiler to create code compatible with earlier Java versions.
For example, in order to generate class files compatible with Java 1.4, use the following command line:
javac -target 1.4 HelloWorld.java
Here 1.4 refers to the JDK version of Jasper Server.

Accessing a library (compiled using higher jdk) gives exception when accessed from lower JRE

I created a jar file (compiled it using jdk1.7). When I used this jar in a project(using JRE 1.6), I get the following exception- unsupported major.minor version 51.0 (I suppose 51.0 is meant for jdk1.7). I used eclipse IDE for all these operations.
I am wondering whether this exception is a norm (in this kind of situation) or is it coming just because class loading in eclipse works differently
This is expected. Bytecode specifically compiled for a java version, can't be executed on a lower version. This is because it might have bytecode instructions and/or features not supported by an earlier Java version.
To compile for a lower java version, you need to explicitly specify the target version of compilation, eg:
javac -target 1.6 ...
In Eclipse you can set this under Properties > Java Compiler > "Generated .class files compatibility". However in general it is advisable to just use a Java 6 compiler to make sure you are actually only using features and libraries included in Java 6.
Class loading is performed by the JVM, both within eclipse and outside of it. This error simply indicates the the file format of class files has changed in Java 7, and a Java 6 virtual machine does't know the class file format from the future.
You can instruct the Java compiler to use the class file format of a previous java version (in eclipse, you can find the setting under Properties -> Java Compiler -> JDK compliance).
In addition, you'll want to verify that you only use API elements that also existed in JDK 6.

GWT upgrade from 2.1 to 2.4

while compiling from GWT 2.1 to 2.4, the following error is shown:
Found interface com.google.gwt.core.ext.typeinfo.JClassType, but class was expected
so kindly provide me with the solution to this issue.
There's a binary backwards-incompatibility in GWT 2.2 (where com.google.gwt.core.ext.typeinfo.JClassType et al. were changed from classes to interfaces). You have to update your third-party dependencies with ones that have been compiled against the GWT 2.2 SDK or a newer version; for your own library or if the third-party lib has been somewhat abandoned, you'll have to recompile it (javac).
GIN for example provides 2 builds of its 1.5 release: one compatible with GWT 2.1.1 and older, and one compatible with 2.2 onwards (there are two distinct JARs in the gwt-1.5.zip download).

compiling scala program on jvm

What version of the scala library jar will support java 1.5 and 1.6
And also how to compile in java?
Scala's jar files are compiled with JVM 1.5, as can be seen by looking into the META-INF/MANIFEST.MF file. Here is 2.8.1: Created-By: 1.5.0_22-b03 (Sun Microsystems Inc.).
The Scala compiler generates output that is compatible with jvm-5 (see scalac -target). Also, it has some magic to enable use with jdk 1.6, in which String has added a method that Scala defines on WrappedString.
Scala is compiled with the scalac compiler and not javac. To run the Scala code you need Java runtime/sdk version 1.5 or later and the scala library jar.
Version 2.7.7 and 2.8.1 are the common versions used today. If you start a new project now you should aim for 2.8.1 or 2.9 (which is going to be available soon-ish). Download site is here
See the FAQ