1

I have a java test project which has two binary fields.when I want to compile the project in IntelliJ,it complains that I should use -source 7 instead of -source 1.6 while compiling.my JDK is the latest.I don't know how to fix this.

sample code:

public class BitWiseTest { static int val1 = 0b01110;//compile-time error static int val2 = 0b11011;//compile-time error public static void main() { System.out.println(val1 & val2); } } 
5
  • You probably have the language level of the project set to 1.6 - this is a setting independent (-ish) of what version JDK you use. Commented Feb 14, 2013 at 16:25
  • 1
    Go to File->Project Structure->Project & Change the project language level to 7.0 & project SDK to 1.7 Commented Feb 14, 2013 at 16:26
  • yes, you should be able to set which jdk you're using inside the IDE Commented Feb 14, 2013 at 16:27
  • @Extreme Coders, you were right.provide an answer to get reputation if you want. Commented Feb 14, 2013 at 16:53
  • @raminomrani All right, thanks for the gesture. Commented Feb 14, 2013 at 16:55

1 Answer 1

3

The issue mainly happens due to incorrect configuration of Project language level set. Thus although you may be using java 7 but since the project language level is configured incorrectly it uses constructs only valid in that language level.Thus you get the error. To fix it follow the steps :

Go to File->Project Structure->Project & Change the project language level to 7.0 & project SDK to 1.7

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.