javaeclipsedebuggingeclipse-jdt

How to debug Java SE 6 using Eclipse 2022-12?


I cannot debug Java SE 6 using Eclipse 2022-12, It throws the following exception:

java.lang.UnsupportedClassVersionError: org/eclipse/jdt/launching/internal/javaagent/Premain : 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)
    at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(Unknown Source)
    at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(Unknown Source)
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main" 

However, I can run this project (Java SE 6) without any problem. I can also run and debug another Java SE 7 normally.

It's same as the problem posted here: https://www.eclipse.org/forums/index.php/mv/msg/1112218/1856754/

It's maybe happen since this change: https://github.com/eclipse-jdt/eclipse.jdt.debug/issues/61

So. is there a way to debug Java SE 6 using eclipse 2022-12, thank you.


Solution

  • TL;DR

    Long story

    A colleague had this problem today and after some tinkering we've got it to work. His Eclipse was also stopping at a ghost breakpoint. He had never ever worked on that project and we had cleaned up everything, but even then, it would stop at a breakpoint and break with the mentioned error.

    After reading the links in this question, now I understand why this worked, but the second item was very unexpected:

    After that, debug was working again.