I think it’s better to change the Cp1252 to utf8 before the file is created if you use utf8. You can find a link on Windows->Preference to change it. Just FYI.
Tag Archives: java
java.lang.UnsupportedClassVersionError
java.lang.UnsupportedClassVersionError
I compiled a few java classes with Eclipse and uploaded on Google App Engine. It didn’t work.
In the logs, it shows:
java.lang.UnsupportedClassVersionError …. minor 51
I googled on the Internet. Someone said:
It means that you compiled your classes under a specific JDK, but then try to run them under older version of JDK.
It spent me quite a lot of time to fix it.
Google App Engine said it supported Java 5 or 6, in other words, jdk1.5.0 or jdk1.6.0.
I added java path to the .ini file. Nothing changed. I think, this step is useless.
On Eclipse, on Windows->Preference. Click “compiler” to open the window, change JDK to 1.6. And JRE’s directory pointed to the JRE6.
It didn’t work. Later on, I found on the windown above, there is a link to remind me to change the JDK of my Application. I did it. Then it works.:))
An example code for using DataStore on Google App Engine
java file
import java.util.Date;
import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.KeyFactory;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.EntityNotFoundException;
import java.io.IOException;
public class DataStore {
DatastoreService datastore = DatastoreServiceFactory.getDatastoreService();
Date putDate = new Date();
Entity entity = null;
String links = “”;
public String createEntity(String headlines, String entity_key) {
entity = new Entity(headlines, entity_key);
entity.setProperty(“Name”, null);
entity.setProperty(“Link”, null);
entity.setProperty(“Date”, putDate);
entity.setProperty(“Description”, null);
datastore.put(entity);
return “create”;
}
public String updateEntity(Key entity_key, String name, String link, String description) {
try {
entity = datastore.get(entity_key);
entity.setProperty(“Name”, name);
entity.setProperty(“Link”, link);
entity.setProperty(“Date”, putDate);
entity.setProperty(“Description”, description);
datastore.put(entity);
} catch (EntityNotFoundException e) {
}
return “update”;
}
public String deleteEntity(Key entity_key) {
datastore.delete(entity_key);
return “delete”;
}
public String getPropertiesOfEntity(Key entity_key) {
try {
entity = datastore.get(entity_key);
String media_name = (String) entity.getProperty(“Name”);
String news_links = (String) entity.getProperty(“Link”);
links = media_name + news_links;
} catch (EntityNotFoundException e) {
}
return “get” + links;
}
public String getLinks() {
String key_str = “H”;
Key entity_key = KeyFactory.createKey(“Headlines”, key_str);
// createEntity(“Headlines”, key_str);
// updateEntity(entity_key, “1”, “2”, “3”);
// deleteEntity(entity_key);
return “Well done” + getPropertiesOfEntity(entity_key);
}
}
jsp file:
<%@page contentType=”text/html” pageEncoding=”UTF-8″%>
<%@ page import=”DataStore” %>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8″>
<title>JSP Page</title>
</head>
<body>
<h1>Hello World!</h1>
<%
DataStore Database = new DataStore();
%>
<%= Database.getLinks() %>
</body>
</html>
All classes on Google App Engine
The JRE Class White List on Google App Engine
http://code.google.com/appengine/docs/java/jrewhitelist.html
App Engine Java Overview