How to fix a java compiling problem with Geany.
- Inicie sesión o regístrese para enviar comentarios
Short answer: Update to openjdk version 8.
The problem:
After downloading Geany 1.32 from the website and installing onto Trisquel 7 64-bit, my .java programs gave the following error when I tried to compile them:
Exception in thread "main" java.lang.UnsupportedClassVersionError: filename : Unsupported major.minor version 52.
The fix:
The problem was fixed after installing some packages:
sudo apt install openjdk-8-dbg openjdk-7-dbg openjdk-7-jdk openjdk-7-demo openjdk-7-source visualvm
Many of these probably didn't help; I installed them because apt recommended them. The package that fixed the problem was probably openjdk-8-dbg. I'm too lazy to check though-- sorry. I had previously installed the following: openjdk-8-jdk openjdk-8-jre openjdk-8-jre-headless.
I can once again compile .java programs with Geany.
It looks like you were trying to run Java 8 code on a Java 7 runtime. (Java is backwards-compatible, but not forwards-compatible!)
If you're triggering it from the command line you need to set the right environment variables. On Trisquel there are helper applications that can assist you. For example:
sudo update-alternatives --config java
This will show you all the versions of Java you have installed. Simply make sure you select version 8 for your code to work.
If this doesn't fix your problem then the next port of call is usually the configuration for your project or IDE. (I've not used Geany before, so I'm going by what the usual solution would be in Eclipse/Netbeans/IntelliJ CE)
- Inicie sesión o regístrese para enviar comentarios