Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Can't resolve JDK issue on Mac

 
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 187
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Recompile the java files into new classes using the new JDK.
 
Mike London
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you running Tomcat standalone, or within the IDE?
 
Mike London
Bartender
Posts: 1865
17
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Sheriff
Posts: 67637
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Cool, glad that you solved it.

And thanks for reporting back with the solution. Good show!
 
Mike London
Bartender
Posts: 1865
17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 think I'll just lie down here for a second. And ponder this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic