4

My eclipse marks every new project with an exclamation mark. enter image description here

i tried the steps provided here: Unbound classpath container in Eclipse but no cigar.

i was able to delete java 1.7 and add the old 1.6 but now i get this error:

java.lang.UnsupportedClassVersionError: klasse : Unsupported major.minor version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)

Exception in thread "main"

im pretty much lost. java seems simply broken to me. maybe i should just reinstall it?

/Edit: since some dont believe me: enter image description here

there is no problem with klasse.java (some other projects have some normal errors that i cannot bother and CSVAufbereitung has the error i had in klasse.java before i followed the steps above.

(thats why i created this question in the first place)

IMPORTANT: i just realized that i only have the jre1.6 installed while having jdk1.7 and jre1.7 installed.

so when i switch back to 1.6 it wont work because i dont have jdk1.6 installed.

silly me. but i would like to keep using 1.7

so the main question is: why is 1.7 not useable anymore ("Unbound")?

Update:

i found out that i can create 1.6 project and they will run without errors.

if i create projects with 1.7 they wont run.

if i then downgrade those projects to 1.6 they still wont run.

since i want to use 1.7 this is quite nagging.

Community
  • 1
  • 1
Wandang
  • 912
  • 2
  • 8
  • 37

4 Answers4

8

Go to Window > Preferences and check Java > Installed JREs, problem is there...

enter image description here

When you change JRE/JDK, you should perform Project > Clean... to force rebuild, this should help.

This "Problems" view I was writing about

enter image description here

And check Shadark's suggestion about compliance level, 1.6 is what you want.

enter image description here

Check also your project Java build path

enter image description here

There are also project compiler settings if "Enable project specific settings" is checked these settings have higher priority.

enter image description here

Betlista
  • 10,327
  • 13
  • 69
  • 110
  • nice hint (didnt know what clean stands for) but it didnt change the outcome. furthermore i have the same settings as you do for installed JREs. thanks for your help! – Wandang May 03 '12 at 14:51
  • checked your compiler settings (if shadark did mean that) and it has the same settings... – Wandang May 03 '12 at 14:59
  • 2
    @Wandang: check also `Java Build Path` of your project (right click on project, last item), there is also `Java Compiler` part – Betlista May 03 '12 at 15:15
  • bam! that did the magic. so setting the compilersettings for the specific project does the trick while saying "project use 1.6" does nothing. quite interesting. i can now code in 1.6jre at least. thanks for your help! – Wandang May 03 '12 at 15:19
3

You should select in build options to build project with Java 1.6 and not 1.7 since you don't have it installed. Hope it helps (I also got unsupported major.minor version error).

Shadark
  • 499
  • 1
  • 7
  • 18
  • You mean project->properties->order and export-> 1.6 marked? thats already the case. thanks anyway for your effort! – Wandang May 03 '12 at 14:57
2

java seems simply broken to me. maybe i should just reinstall it?

That is unlikely to be the problem / solution.

Indeed, the fact that Eclipse is running at all is a clear sign that you have a viable Java installation; i.e. the one that Eclipse is using to run.

I suggest that you look in the Eclipse "Problems" view and read the error messages associated with the flagged projects. It is likely to be a problem with either the project(s) or Eclipse's workspace preferences.


Other things you could try include refreshing the workspace (F5) and restarting Eclipse.


Also look at the "Errors" view and / or the Eclipse error log to see if it contains any messages / stacktraces that might point you in the right direction.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
  • as stated above i dont have any "problems" in my view. still exceptions are thrown. java and javac in cmd do respond correctly. java should be installed correctly as you stated – Wandang May 03 '12 at 14:46
2

First, you should start your class names with an uppercase letter:

public class Klasse {

Second, when you right click on your project and go to Properties, then go to Java Build Path, you should have your Java library listed here. Is it listed as a JRE System Library? You can add it correctly by clicking on Add Library... -> JRE System Library -> Next -> and then choose either the workspace default or an alternate JRE.

Your stack trace dump just looks like there is no JRE added to the project.

If your problem can not be solved by this, you can go to Window -> Show View -> Problems. There you can sometimes find some additional information. Most likely, something is wrong with your project setup.

brimborium
  • 9,362
  • 9
  • 48
  • 76
  • I fact, class named with lowercase does not follow naming conventions, but it is a valid name. – Betlista May 03 '12 at 14:44
  • i found 1.6 jre as system lib and it was not marked for some reason. i marked it but the problem persists. thanks for the try! PS: i cannot add 1.7 since its "unbound" i dont know what that means – Wandang May 03 '12 at 14:44
  • i write classes in lowercase when i create testclasses which is now the case. ;) – Wandang May 03 '12 at 14:46
  • 1
    Well, you should'nt ;). As Betlista stated, it does not follow the naming conventions. You could instead just add Test, like this `public class TestKlasse {`. – brimborium May 03 '12 at 15:39