I'm using Intellij Idea 15.0.1 and have a Java project, it imports class of default package from the class of a named package.
Since it is allowed only in Java 1.3, I've set JDK 1.3 everywhere:
- Project Settings
- IDE Settings - Java Compiler
- Edit Configurations (Application)
But still when I make project it stops with "Cannot resolve symbol" error. Also making starts with the message:
Information:Using javac 1.8.0_51 to compile java sources
Why Idea still uses javac 1.8 and how to set java 1.3 for the whole project, including syntax highlight?
You need to install JDK 1.3, configure it in Project Structure | SDKs and select it as the project SDK in Project Structure | Project.
Related
I have a project with many modules, all of which need to be compiled using Java 7. I have made sure every setting that I know of to point to that version of Java, yet somehow, every time I rebuild the project I get:
Information:javac 11.0.3 was used to compile java sources
followed by a list of errors:
Warning:(86, 25) java: as of release 9, '_' is a keyword, and may not be used as an identifier
Error:(86, 25) java: cannot find symbol
symbol: class _
location: class com.(...)`
Following other questions like:
Can't resolve -source errors on IntelliJ with regards to Project Language Level
IntelliJ IDEA tells me "Error:java: Compilation failed: internal java compiler error idea"
I have tried these settings:
Under Project Structure -> Project -> Project SDK: 1.7
Project Structure -> Project language level -> 7 - Diamonds, ARM, multi-catch etc.
Under Project Structure -> Modules checked every module, and that was not fun, because there are about 50. Sources tab -> Language level: Project detaulf (7 - Diamonds, ARM, multi-catch etc.)
Project Structure -> Modules, each Dependencies tab -> Module SDK: Project SDK (1.7)
Project Structure -> SDKs: it listed IDEA's built in Java 11, so I removed it, leaving only: 1.7
Settings -> Java Compiler -> Use compiler: Javac
Settings -> Java Compiler -> Use compiler from module target JDK when possible: unticked
Settings -> Java Compiler -> Per-module bytecode version: all modules set to 1.7
I am running the latest version of IntelliJ IDEA:
IntelliJ IDEA 2019.2 (Ultimate Edition) Build #IU-192.5728.98, built on July 23, 2019
Is this a bug with IDEA?
Here is the reason Intellij is choosing java 11:
https://www.jetbrains.com/help/idea/configuring-build-jdk.html
IntelliJ IDEA checks all JDKs that are used in the project: the JDKs
that are defined on both the project and module levels.
IntelliJ IDEA calculates the latest of these JDKs. This is necessary
to make sure that all modules can be compiled.
If the version of the latest JDK configured is lower than 1.6,
IntelliJ IDEA will pick the JDK version that is used for running the
IDE. This limitation is related to the fact that the compiler API used
by IntelliJ IDEA for building projects is supported starting from JDK
1.6.
And that is why switching the boot JDK to JDK8 re-enables the compilation of older java classes.
As mentioned in the comments by #Arnaud Claudel, I have tried switching the boot JDK of IDEA (described here https://www.jetbrains.com/help/idea/switching-boot-jdk.html) which helped. Incidentally, the lowest JDK version that IDEA will accept is 8.
I am not sure it is actual solution though and not just a workaround, because why would the IDE use JDK 11 in the first place, ignoring all the project's settings.
So I am leaving this question open for anyone to post a better solution.
I've recently updated to IntelliJ IDEA 2016.3 and I just noticed that whenever I have a project with a java 7 SDK selected, IntelliJ compiles the project with java 1.8.0_112-release (which must be a compiler bundled with IntelliJ because I have never installed it myself).
If I select a java 8 SDK other than the 1.8.0_112-release, IntelliJ compiles with that compiler.
If I have a java 7 SDK selected and run a main method in my project, IntelliJ uses that java 7 SDK version to run so the issues seems to only relate to the compiler.
I have tried re-installing all my java installations.
When I change the SDK I usually only change Project Structure -> Project -> Project SDK, but I also verify that the Language level is correct and that Project Structure -> Modules -> Dependencies -> Module SDK is correct.
All settings are default under:
Settings -> Build, Execution, Deployment -> Compiler/Java Compiler
It seems to me that IntelliJ IDEA 2016.3 is not able to use a java compiler lower than java 8, but my googling attempts have not been able to confirm this.
I can also mention that the only thing I haven't tried yet is a hard uninstall of IntelliJ where all my settings are wiped as well. A silent uninstall have been tried.
If I try to compile a new Hello World project with a Java 7 SDK this is the output in the Messages tab: Information:Using javac 1.8.0_112-release to compile java sources. If however I set the project SDK to a Java 8 SDK this is the output in the Messages tab: Information:Using javac 1.8.0_45 to compile java sources.
Have tried setting Settings -> Build, Execution, Deployment -> Compiler -> Java Compiler -> Project bytecode version to 1.7 without any effect.
File -> Other Settings -> Default Project Structure -> Project SDK and Project language level set to the Java 7 SDK. Message tab still displays: Information:Using javac 1.8.0_112-release to compile java sources
Has anyone else experienced this and know what causes this behaviour?
You need to set 2 things:
CTRL + ALT + SHIFT + S --> Project --> Project SDK
CTRL + SHIFT + A --> Type "Java Compiler" --> Target Bytecode Version
Apparantley this was caused by an issue in IntelliJ as stated in this
issue.
It has been resolved as of IntelliJ IDEA version 2016.3.1 and I copy-paste the comment from Eugene Zhuravlev in the youtrack issue to explain how it has been fixed:
A new compiler option has been introduced for javac: File | Settings | Build, Execution, Deployment | Compiler | Java Compiler | "Use compiler from module target JDK when possible". The default value is "on".
When this property is enabled and JDK associated with the module differs from the build's own JDK, the build will prefer compiling with the javac from the associated JDK rather than the compiler from the JDK it runs on.
there is a distiction between Project Structure and Default Project Structure (the latter is for newly created/checked out Projects).
Default Project Structure hides in File -> Other Settings.
There you would have Project SDK and Project Language Level.
Have a java project with couple of main java classes in it. On server this program has to run using java 1.5 version.
Trying to setup the same in eclipse.
Project properties/Java compiler ---- set to 1.5
Project properties/Java build path ---- Added JRE library ---> J2SE-1.5
But, when running one of the main class in the project in eclipse getting error as
SEVERE: Java Runtime Environment (JRE) version 1.6 is not supported by this driver
what else do I need to do in eclipse to run the program using java 1.5??
Go to Window -> Preferences -> Java -> Compiler and choose the default compliance level as 1.5
In Project properties/Java compiler make sure that 'Enable project specific settings' is checked.
Also, I would double check the build path for duplicate JRE libraries
I'm new in java and storm
i imported a project in eclipse with the needed library and i got errors in some code
The code of the project i imported here
https://github.com/nathanmarz/storm-starter .
and i run pom.xml using Maven .. Build Successfully .
I'm using eclipse Kelper Jee Release .
the photo i upload it show more about my problem .
`
what about warning i have . it's suppose for project ... work well ? am i ignore it or no ?
... must override a super class ... is because the project's Java compiler compliance level is 1.5 but it needs 1.6. Java 1.5 does not allow #Override annotations on methods implementing interface methods. Try right click on project -> Properties -> Java Compiler set compliance level 1.6 or 1.7
Looks like there is problem in version of jars that you are using.
Go To Window -->Preference Check Java Compilation level,Check your java Build path JRE included correctly or not JRE version is Low Find 1.6 instead of 1.5
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.