I'm using Drools (5.5.0) rules in my Java project (managed using maven 2.2.1). It works fine in Java 6 (1.6.0_45), but when I move to Java 7 (1.7.0_51) and build, certain rules give a rule compilation error such as the following:
Rule Compilation error : [Rule name='SampleRuleName']
com/sample/event/rules/simple/Rule_SampleRuleName46467274.java (2:486) : Syntax error, static imports are only available if source level is 5.0
com/sample/event/rules/simple/Rule_SampleRuleName46467274.java (2:500) : The import com.sample.event.rules.simple.TransformEvent.transformEvent cannot be resolved
com/sample/event/rules/simple/Rule_SampleRuleName46467274.java (7:1082) : The method transformEvent(TransformedEventCallBackHandler, EventTemplate, FirmwareEvent) is undefined for the type Rule_SampleRuleName46467274
The "static imports are only available if source level is 5.0" error suggests the drools compiler is setting a source level less than 5, but why would it do that? I've update my JAVA_HOME and my pom.xml. It should be picking up the Java source level from there, right?
Upgrade to Drools 6, this issue is fixed there. We had a similar issue for Java 8 recently with Drools 6.0 and it's fixed for 6.1 (and recent versions of 6.0 too).
The cause for java 8 was that drools recognizes java versions 1.6, 1.7, but not 1.8 at which point it defaults to 1.6. I suspect that drools 5.5 (which is old) had the same problem for java 7.
Turns out Drools uses the Eclipse JDT compiler to compile rules. Upgrading the JDT version did the trick. However if that fails, upgrading the Drools version might also help.
Related
I am using jdk9-ea 149 and created a sample javafx application
IntelliJ doesn't understand the java libraries, It's shows all the import statement in red color and they are all grayed out.even for java.util.List, java.util.ArrayList it has the same issue.
I am able to compile form outside but i am not able to compile the code from IntelliJ 2016.3.2 Ultimate Edition.
It looks like we need to add some libraries to IntelliJ project but with java9 build 149 jigsaw i don't know how to do that.
I am using Experimental features still it doesn't understand the import statements - see intellij setting below
IntelliJ Version : IntelliJ 2016.3.2 Ultimate Edition
Java Version: java 9-ea build: 149
As mentioned in IntelliJ IDEA 2016.3.1 is Out:
Speaking of JDK 9, IntelliJ IDEA 2016.3 won’t support builds 148 and up because they contain code that breaks things. Of course, we’re working to resolve this, and will support the latest JDK 9 builds in 2017.1 (its EAP may well start within the next few weeks).
In IntelliJ IDEA 2017.1: Java 9, Kotlin 1.1, Spring, Gradle, JavaScript, Go and more it says:
The latest builds of JDK 9 are fully supported, with assisted project import and coding assistance for editing module declarations.
So if you are using Java 9 build 148 or higher, you need to use version 2017.1 or higher.
Alternatively, if you need to use an older version of IntelliJ, downgrade to Java 9 build 147 or lower.
The latest version of IntelliJ IDEA, 2017.1, does support jdk 9.
It's my first question on stackoverflow since I'm having an issue that's driving me crazy!
I'm trying to compile an old Android project (it was made about a year ago) and I'm using the Eclipse Luna IDE, the same IDE I used to develop my app. When I was developing I had Java 7 but since then I had installed Java 8. So, when I'm trying to run my app that
"Unsupported major.minor version 52.0 "
error comes up.
I've tried the solutions that suggest to change the jre in the Java Build Path and Java Compiler properties of the project but when I change the jre the Eclipse console gives me this error:
"Android requires compiler compliance level 5.0 or 6.0. Found '1.8'
instead. Please use Android Tools > Fix Project Properties."
When I apply the suggested solutions, the first error comes up again. It's an either this or that situation.
I feel like I'm in an infinite loop! Can somebody please help?
I have Windows 7, Eclipse Luna IDE jdk1.7.0_79 and jdk1.8.0_92 installed.
I have the same problem. I fixed it:
project-properties- Java Build Path -Libraries - Add library -Jre system library - I put into jdk1.7,
project-properties- Java Compiler - change to 1.7
All done.
Change your compiler target level to Java 1.5 or 1.6 and it should be working.
I need to use PMD, Findbugs and Checkstyle in Eclipse for a Development project. Is Java 6 enough to use these tools? or I need java 7?
Java 6 is enough (Even 5 will work).
Everything should work for
1.5>=Java<1.8
Findbugs
FindBugs requires JRE (or JDK) 1.5.0 or later to run. However, it can
analyze programs compiled for any version of Java, from 1.0 to 1.7.
Some classfiles compiled for Java 1.8 give FindBugs problems, the next
major release of FindBugs will handle Java 1.8 classfiles.
http://findbugs.sourceforge.net/
Checkstyle
Added Java 7 support to the grammar. Thanks to Dinesh Bolkensteyn for
patch #3403265
http://checkstyle.sourceforge.net/releasenotes.html
PMD
•2011-11-04 PMD 4.3 (download): ◦Add support for Java 7 grammer -
thanks to Dinesh Bolkensteyn and SonarSource
http://pmd.sourceforge.net/pmd-4.3/
Notice latest PMD requires Java 7/8
running PMD only requires Java 7 (or Java 8 for Apex and the Designer).
I'm using Ant to compile Java.The project has to be compiled using JDK 1.5 , however some part of the code references a package compiled with JDK 1.6 version.
I set the JAVA_HOME to 1.5 , error is thrown at this reference as
[javac] class file has wrong version 50.0, should be 49.0
What is the way out without downgrading the reference version to 1.5
What you are asking isn't possible. You should compile your library with JDK 1.5.
Once Java has been compiled at a certain version, you cannot use that version on older versions of Java.
The package you are using might have a version available which is suitable for an older version of Java, alternatively you may be able to get the source code and recompile with the older version (if it doesn't use any Java 6 libraries / features).
Think this way:
The library you use has been compiled using JDK 6. It may be using some features introduced in Java 6 (that were not part of previous versions of Java)
When you use JDK 5 to compile and run, what do you expect the compiler (and the runtime) to do when this "new" feature is encountered? The JDK 5 does not know this feature and will be "confused"
To avoid this confusion at runtime, the compile itself fails.
You have two options:
Compile your project using JDK 6.
Get a JDK 5 compiled version of your library
If your project were using JDK 6 and the library was compiled with JDK 5, then you wouldn't have faced this issue because of backwards compatibility.
I am working an application with JXL API and when i tried compiling using eclipse IDE, it's working fine and the same is not compiling when i am trying to compile in Command prompt and showing the below exception..
Extract.java:6: cannot access jxl.read.biff.BiffException bad class file: C:\Program Files\Java\jdk1.5.0_01\jre\lib\ext\jxl.jar(jxl/read/biff/BiffException.class)
class file has wrong version 50.0, should be 49.0
Please remove or make sure it appears in the correct subdirectory of the classpa
th.
import jxl.read.biff.BiffException;
^
1 error
EDIT:
I am able to executing using JDK 1.6. Since JDK 1.6 must also be compatible with lower versions, why doesn't it support the class files which were compiled in JDK 1.5.
The library you're using was compiled with Java 6
Your compiler is Java 5 that's why it doesn't understand that format.
To fix it you have to get a 1.5 version of the library or upgrade your compiler to 1.6 I suggest the later.
Per http://www.jnode.org/node/2140...
Submitted by Stephen Crawley on Fri, 11/30/2007 - 07:15.
I suspect that you are mixing code compiled with different versions of Java. Class file version 50.0 is used by Java 6.0, and 49.0 is used by Java 5.0.
Try doing a "build clean" to get rid of all existing class files, followed by a regular build.
JNode is being developed using Java 6.0 only. Last time I tried, it didn't build using Java 5.0 (aka 1.5). (It is a problem with the program that builds the JNode boot image.)
Try changing the builder in Eclipse. If you're using 3.4, it's Project - Properties - Java Compiler - Enable Project Specific Settings - Compiler Compliance Level = 1.6. You'll prolly also need to have JRE 1.6 installed, as well.
Check you class path in eclipse and make sure that its the same class path your compiling to in the command prompt, also check your library imports
It means that, you have compiled that class with Java 6 and trying to execute with Java 5.
Solution :
If your using ant, execute below steps on the project root directory
ant clean
ant deploy
If your using eclipse, just
clean the workspace(remove the class files which were compiled with Java6)
and build again
this could be that in you IDE you point to latest version of JDK but when you build your program outside the IDE(maybe with maven) your java_home is the older version to the one on your IDE.