xenia27
asked on
javax.script cannot be resolved
I try to call functions in javascript with java program. I found some information and tried implement it. However, I got this error message," [ERROR] Line 5: The import javax.script cannot be resolved". What's wrong with my code?
I am using JRE 1.6.0.13 with eclipse.
I am using JRE 1.6.0.13 with eclipse.
package com.xenia.googleproject.server;
import javax.script.*;
import com.xenia.googleproject.client.GreetingService;
import com.google.gwt.user.server.rpc.RemoteServiceServlet;
/**
* The server side implementation of the RPC service.
*/
@SuppressWarnings("serial")
public class GreetingServiceImpl extends RemoteServiceServlet implements
GreetingService {
public String greetServer(String input) {
String serverInfo = getServletContext().getServerInfo();
String userAgent = getThreadLocalRequest().getHeader("User-Agent");
return "Hello, " + input + "!<br><br>I am running " + serverInfo
+ ".<br><br>It looks like you are using:<br>" + userAgent;
}
public String getClientAddr(String latitude, String longitude, String city, String country, String country_code, String region){
String addr = new String();
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine jsEngine = mgr.getEngineByName("JavaScript");
Invocable invEngine = (Invocable)jsEngine;
try{
jsEngine.eval("function getClientLocation(lat, lng, city, country, country_code, region)"
);
invEngine.invokeFunction("getClientLocation", latitude, longitude, city, country, country_code, region);
} catch (ScriptException ex){
ex.printStackTrace();
} catch (NoSuchMethodException ex){
ex.printStackTrace();
}
addr = city;
return addr;
}
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Its the compiler settings. change it from 1.5 to 1.6
I think there are around 3 sections to change in eclipse.
To make it simple, just remove or uninstall 1.5 & 1.6 & Install 1.6
This should help.
I think there are around 3 sections to change in eclipse.
To make it simple, just remove or uninstall 1.5 & 1.6 & Install 1.6
This should help.
ASKER
I think I have the compiler set to 1.6...Please check the attachement...
compiler.JPG
compiler.JPG
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
OK...I finally got what you meant and it worked!! I uninstalled everything and reinstalled JDK 1.6 only...
Thank you!!
Thank you!!
ASKER