GeeCON Prague 2014*
The moose likes Servlets and the fly likes class file has wrong version 50.0, should be 49.0 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "class file has wrong version 50.0, should be 49.0" Watch "class file has wrong version 50.0, should be 49.0" New topic
Author

class file has wrong version 50.0, should be 49.0

maya brown
Ranch Hand

Joined: Feb 18, 2009
Posts: 42
hi, I get this error: class file has wrong version 50.0, should be 49.0

when trying to compile a servlet containing JSON code.. (any other servlets compile ok...)

I have json.jar in proper place (I even ran jar tf json.jar command, everything is there..) am running jdk1.5.0_18 and this is specified in JAVA_HOME...

don't know what's up with my tomcat/JSON.. also in JSP I can't run JSON code, get errors like

JSONObject cannot be resolved to a type

even though, again, json.jar is in its proper place, and proper directive is in JSP to import JSON classes...

am on tomcat 5.5

would appreciate suggestions.. thank you..


maya brown
Ranch Hand

Joined: Feb 18, 2009
Posts: 42

I'm trying to run example here, http://www.learn-ajax-tutorial.com/Json.cfm#h1.2

he has this line in JSP:

JSONObject objJSON = (JSONObject) JSONValue.parse(strJSON);

get error on JSONValue, where does JSONValuecome from, I don't see JSONValue here, http://www.json.org/javadoc/index-all.html#_J_

he imports org.json.simple, where does he get THAT from, there's no class SIMPLE in org.json.. I changed that directive to just org.json.*, but still get errors...

(I also don't see method parse() here, http://www.json.org/javadoc/index-all.html#_P_) am I on drugs or is he??? ;~)

thank you..

Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42031
    
  64
I get this error: class file has wrong version 50.0, should be 49.0

That sounds like you're using a library that is compiled for use with Java 6, while you're using Java 5. Either recompile the library to work with Java 5 (assuming that's possible, but chances are that it is), or find another library that works with java 5 out of the box, or upgrade your JDK to Java 6.

even though, again, json.jar is in its proper place, and proper directive is in JSP to import JSON classes

By "proper place" you mean your web app's WEB-INF/lib directory, right? Post the JSP directive.

where does JSONValuecome from, I don't see JSONValue here ... he imports org.json.simple, where does he get THAT from, there's no class SIMPLE in org.json..

The footnote on that page tells you where to get the required files.

But in general, note this paragraph under "JSON parsers -> on the server-side", which I take to mean that you should adapt the code to whatever JSON library you happen to use:
Decode the incoming JSON string and convert the result to an object using a JSON parser for the language of your choice. At http://www.json.org, you'll find JSON parsers for many modern programming languages. The methods available depend upon which parser you are using. See the parser's documentation for details.


Ping & DNS - my free Android networking tools app
maya brown
Ranch Hand

Joined: Feb 18, 2009
Posts: 42

oh brother... just like you say, what probably happens is the json.jar I got was compiled with Java 6

I guess I have to get src code (available at json.org) and compile myself..


thank you very much..

maya brown
Ranch Hand

Joined: Feb 18, 2009
Posts: 42

oh man.. I got src code, compiled all classes, put in json.jar put json.jar in <appName>WEB-INF/lib.. but get EXACT SAME error I was getting before..

JSONObject cannot be resolved to a type

again, this is for example here, http://www.learn-ajax-tutorial.com/Json.cfm#h1.2

(and, again, I changed the import of org.json.simple.* to just org.json.* since org.json.simple.* doesn't make sense to me, but in both cases I get same error...)

thank you...




Mark E Hansen
Ranch Hand

Joined: Apr 01, 2009
Posts: 643
Can you please provide the full error you're getting?

When are you getting this, during compilation? Is a stack trace provided? Can you please show this? (use code tags)

As far as the import goes, what is the fully-qualified package name of the objects you are referencing in your source file? That will tell you what you want for import statements. For example if the class you're referencing is com.company.product.MyClass, then you can use the following import: If you really want to, you can use glob characters in the import, so instead you could use the following:

If the class you're trying to reference needs an import which you don't have, you'll get a different error, so I don't think that's what's happening here (although your last posted error message was pretty vague, so I'm not sure).
maya brown
Ranch Hand

Joined: Feb 18, 2009
Posts: 42
ok, here it is online..
http://mayacove.com/ajax/json_ex.html

(it may take a wink or two till buttons react, not sure why... at any rate get error on both buttons...)

JSP code for ReceiveJSON.jsp is exactly what it appears here:
www.learn-ajax-tutorial.com/Json.cfm#h1.2

EXCEPT I changed this:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.net.*,org.json.simple.*"%>

to this:

<%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1" import="java.net.*,org.json.*"%>


org.json.simple.* didn't make sense to me, as I don't see a package "simple" here,
www.json.org/javadoc/index.html

in WEB-INF/lib/ I have json.jar, compiled by myself (from src code gotten from here, www.json.org/java/index.html) on sdk 1.5...
( & tomcat is 5.5....)

thank you..






 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: class file has wrong version 50.0, should be 49.0