LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-04-2014, 10:25 AM   #1
FooIsFood
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Rep: Reputation: Disabled
Unsupported major.minor version 52.0


Hello,
I have seen this posted before, so I know there is a solution somewhere. It seems as though I have a version conflict between Java versions (compiler vs. runtime) - here is the issue, I compile a version of my test app, very simple, it compiles just fine - console application (not applet, for the moment, I am not targeting applets), I try to run it and get "Unsupported major.minor version 52.0" - I would like to run under version 1.8 - how do I fix this definitively. Don't pull punches, I want to compile targeting version 1.8 and run under version 1.8. What do I do?
This simple code fails:
code start:

public class HelloWorld
{
public static void main(String[] args)
{
System.out.println( "Hello world!");
}
}

code end
compile dump returns no error. Try to run, I get:
java HelloWorld
Exception in thread "main" java.lang.UnsupportedClassVersionError: HelloWorld : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
ABRT problem creation: 'success'
What is the problem here and what are the step by step solutions for it?
Thanks
 
Old 07-05-2014, 06:17 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Your JDK and JRE might be of different versions. Try commands like these:
Code:
which javac
which java
javac -version
java -version
 
Old 07-05-2014, 10:08 AM   #3
FooIsFood
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
okay, here is what I have:
javac -version
javac 1.8.0_05

java -version
java version "1.7.0_60"
OpenJDK Runtime Environment (fedora-2.5.0.1.fc20-x86_64 u60-b30)
OpenJDK 64-Bit Server VM (build 24.60-b09, mixed mode)

Does this help?
Thanks
 
Old 07-05-2014, 11:44 AM   #4
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Well, then find a way(*) that the two versions be the same.
Or, alternatively try and compile with these options:

Code:
javac -source 1.4 -target 1.4 HelloWorld.java
(*) Via installing/updating packages, setting/changing environment variable PATH and JAVA_HOME, creating symlinks or whatnot. Ask your sysadmin for help.

Note: if you have JDK installed, it has a JRE in it, use that.

Last edited by NevemTeve; 07-05-2014 at 11:49 AM.
 
Old 07-05-2014, 12:23 PM   #5
FooIsFood
LQ Newbie
 
Registered: Mar 2014
Posts: 11

Original Poster
Rep: Reputation: Disabled
Thanks.
That worked for the simple code, but, the real code won't compile under 1.4, where do I get the *right* versions so the compiler and the runtime work together?
Thanks again.
 
Old 07-05-2014, 05:04 PM   #6
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,868
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Kindly read the last parts of my previous post.
 
  


Reply

Tags
java



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Major and Minor numbers with partitions raj_hcl1986@rediffma Linux - Newbie 3 05-12-2013 06:07 PM
why i cant get man major() or minor() henryluo Programming 5 06-27-2005 02:39 AM
How to determine major, minor programatically markjuggles Programming 1 04-15-2005 01:09 PM
major/minor number zyan Linux - Newbie 2 06-25-2001 06:57 PM
major /minor number zyan Linux - General 0 06-22-2001 02:26 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 05:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration