wood burning stoves 2.0*
The moose likes Servlets and the fly likes Can't resolve JDK issue on Mac Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Can Watch "Can New topic
Author

Can't resolve JDK issue on Mac

Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
Hi all,

I've updated Tomcat to version 7, the JDK to version 7, and the run-time to version 7.

---------------------

Yet, when I run the application's Servlet (http://localhost:8080/TestServlet/MyServlet), I get this error:

type Exception report

message net/test/servlets/MyServlet : Unsupported major.minor version 51.0 (unable to load class net.test.servlets.MyServlet)

description The server encountered an internal error that prevented it from fulfilling this request.

exception

java.lang.UnsupportedClassVersionError: net/test/servlets/MyServlet : Unsupported major.minor version 51.0

-------

But, doing a javap -verbose gives me (for this Servlet):

SourceFile: "MyServlet.java"
minor version: 0
major version: 51


***** and, at the command line, "java -version" gives me:

java -version
java version "1.7.0_10"
Java(TM) SE Runtime Environment (build 1.7.0_10-b18)
Java HotSpot(TM) 64-Bit Server VM (build 23.6-b04, mixed mode)


-------------------

If I run the project directly from the IDE and it brings up the browser, then it works.

-------------------

(Tomcat log has no reported problems.)

I noticed that in "/System/Library/Frameworks/JavaVM.framework", under CurrentVersion it still says 1.6 so that could be the problem, but I don't know how to change that.

I was thinking that installing the latest Java 7 to
"/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk" would update the current version.

How do you update the current version "setting" on a Mac in /System/Library/Frameworks/JavaVM.framework (if you need to, that is)? Going into System Preferences already says it's 1.7.0.

--------------------

Within the IDE (Intellij IDEA 12) everything is set to Java 7 so I'm really at wits end trying to nail this one down. If I change the Java version to Java 6, then the Servlet loads/works.

What else is there to look at?

Look forward to any suggestions.

Thanks in advance.

- m
Emanuel Kadziela
Ranch Hand

Joined: Mar 24, 2005
Posts: 186
Recompile the java files into new classes using the new JDK.
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
Emanuel Kadziela wrote:Recompile the java files into new classes using the new JDK.


Maybe you missed the part of my posting where I said the Servlet...

SourceFile: "MyServlet.java"
minor version: 0
major version: 51

(That's correctly Java 7, so that's not the problem.)

Thanks anyway for your reply.

-Mike
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Are you running Tomcat standalone, or within the IDE?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
Bear Bibeault wrote:Are you running Tomcat standalone, or within the IDE?


Hi Bear,

Lots of blind alleys....another day shot due to Java configuration Bull****.

In any case, the problem was that I needed to substitute the "New" line below at the top of catalina.sh for what was there. You have to be careful since Tomcat puts another /bin in there for you automatically. Once I realized what was happening in the Echo, it was quickly fixed.

# OLD
# export JAVA_HOME=/Library/Java/Home (Pointed to a 1.6 version of the JDK)

#New - works!
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_10.jdk/Contents/Home

------

To answer your question, running it from Intellij worked fine since I suppose it manages things better. The problem happened trying to just run the simple Servlet directly in Tomcat. The JSP was fine, but not the Servlet.

In any case, I just got it working 2 minutes ago and logged back on to post this update in case it might help someone else not spend 7 hours pulling their hair out.

Thanks very much, as always, for your kind reply.

-- Mike
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60766
    
  65

Cool, glad that you solved it.

And thanks for reporting back with the solution. Good show!
Mike London
Ranch Hand

Joined: Jul 12, 2002
Posts: 1043
Bear Bibeault wrote:Cool, glad that you solved it.

And thanks for reporting back with the solution. Good show!


You bet. Seems like a relatively often occurring problem. Hopefully people will find my post.

Have a good one!

Thanks again.

- Mike
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Can't resolve JDK issue on Mac
 
Similar Threads
Understanding creating a "super" class obj from a "subclass" object
Give the easiest example which differentiate "interface" and "abstract class" in Java.
packages and CLASSPATH
SQL error
The "this" keyword and the constructor.