2

I am beginner in Java programming. Here is my question:

It says Java SDK 1.8. I am confused. What is the relationship between Java SDK 1.8 and java version 6 or 8?

Here is a picture in intelliJ.

enter image description here

It says Java SDK 1.8. It prevents me using a try-with-resouese, which is available in Java 7.

How do I find out which Java version that IntelliJ is using in my current project?

Jonathan
  • 20,053
  • 6
  • 63
  • 70
Nicolas S.Xu
  • 13,794
  • 31
  • 84
  • 129
  • http://en.wikipedia.org/wiki/Java_version_history – user3159253 Jan 09 '15 at 09:22
  • Particularly see the difference between "marketing versioning" and "developer versioning" – user3159253 Jan 09 '15 at 09:22
  • 5
    You may need to change the project's language level. Check [here](https://www.jetbrains.com/idea/help/project-general-settings-page.html) for instructions. – Jonathan Jan 09 '15 at 09:23
  • Basically developers call "1.8" what Sun/Oracle marketing department calls "8". – user3159253 Jan 09 '15 at 09:23
  • 1
    what is your build system ? if gradle - can you try adding `compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 }` – kiranpradeep Jan 09 '15 at 09:28
  • As Jonathan and Kiran have already explained, just in other words: you have Java 8 installed, but probably the IDE (or your project) is configured to validate code for older Java versions (compatibility). You just need to make sure that you work with Java 8 compatibility. If you don't find it, maybe someone who uses IntelliJ can help you (I use Eclipse)... – Martin Jan 09 '15 at 09:39
  • possible duplicate of [What is Project Language level in IntelliJ\_IDEA?](http://stackoverflow.com/questions/17714584/what-is-project-language-level-in-intellij-idea) – Jonathan Jan 09 '15 at 09:46

1 Answers1

1

Java 8 and 1.8 are the same. As several people pointed out in the comments. The difference is between marketing and developer version numbering. Take the "1." off the front to get the marketing version.

To enable the use of Java 7 and 8 features in IntelliJ open the project structure dialogue. (File > Project Structure...) In the project section there is a "Project Language Level" drop down. Select the one for 7 or 8 to enable the use of the try with resource feature.

Wil Selwood
  • 1,112
  • 2
  • 11
  • 19