Results 1 to 2 of 2
- 01-28-2009, 11:51 AM #1
Member
- Join Date
- Jan 2009
- Posts
- 2
- Rep Power
- 0
rmi when running server and client
Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n
umber in .class file
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java :620)
at java.security.SecureClassLoader.defineClass(Secure ClassLoader.java:12
4)
at java.net.URLClassLoader.defineClass(URLClassLoader .java:260)
at java.net.URLClassLoader.access$100(URLClassLoader. java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java: 195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.j ava:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:3 06)
at sun.misc.Launcher$AppClassLoader.loadClass(Launche r.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:2 51)
at java.lang.ClassLoader.loadClassInternal(ClassLoade r.java:319)
My server
ackage BIConsulting.java;
import java.io.*;
import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.util.Map;
import java.rmi.server.UnicastRemoteObject;
import java.util.Set;
import java.util.Iterator;
public class Bserver extends UnicastRemoteObject implements BInt
{
public Bserver()throws RemoteException{
super();
}
String error = null;
String output = null;
public String getError()
{
return error;
}
public String getOutput()
{
return output;
}
/** Called from inside the jsp like new Console().exec("cscript drucken.vbs param1 param2") **/
public int exec(){
int exitVal=9999 ;
try{
int count=0;
int Valuecnt=0;
Map map = System.getenv();
Set keys = map.keySet();
Iterator iterator = keys.iterator();
String key =null;
String value = null;
while (iterator.hasNext())
{
key = (String) iterator.next();
if (key.toLowerCase().equals("bicpath"))
{
value = (String) map.get(key);
count=count+1;
break;
}
}
if(count!=1)
{
Valuecnt=0;
}
if (value == null)
{
Valuecnt=0;
}
if (value.length() == 0)
{
Valuecnt=0;
}
boolean exists = (new File(value)).exists();
if (exists)
{
// System.out.println("Exists");
Valuecnt=1;
}
else
{
// System.out.println("Does not Exists");
Valuecnt=0;
}
if (count == 1)
{
if (Valuecnt== 1)
{
String osName = System.getProperty("os.name" );
String[] cmd = new String[3];
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2]=value+"\\BICEXE.exe";
// cmd[2]="E:\\NewFolder\\BICEXE.exe";
//cmd[2] = "C:\\windows\\notepad.exe";
//cmd[2] = "C:\\windows\\Console_JSP.exe";
//cmd[2] = "C:\\windows\\test.bat";
//cmd[2]="E:\\NewFolder\\test.bat";
// cmd[2]="E:\\NewFolder";
//cmd[4]="Console_JSP.exe";
//cmd[2]="E:\\NewFolder\\Console_JSP.exe";
//cmd[2]="E:\\NewFolder\\test.bat";
Runtime rt = Runtime.getRuntime();
//System.out.println("Execing " + cmd[0] + " " + cmd[1] + " " + cmd[2]);
Process proc = rt.exec(cmd);
exitVal = proc.waitFor();
// System.out.println(exitVal);
// any error message?
grabStream(proc.getErrorStream(), "error");
// any output?
grabStream(proc.getInputStream(), "output");
// any error???
//int exitVal = proc.waitFor();
//if (exitVal != 0)
// error += "ExitValue: "+exitVal;
}
}
}
catch (Exception e)
{
e.printStackTrace();
}
return exitVal;
}
private void grabStream(InputStream is, String msg)
{
if (!(msg.equals("error") || msg.equals("output")))
return;
String message = "";
try{
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line=null;
while ( (line = br.readLine()) != null)
message += line;
} catch (IOException ioe){
ioe.printStackTrace();
}
if (msg.equals("error"))
error = message;
else
output = message;
}
public static void main(String args[]) throws RemoteException, MalformedURLException{
//if(System.getSecurityManager()==null){
// System.setSecurityManager(new RMISecurityManager());
Bserver bi= new Bserver();
// bi.exec();
Naming.rebind("BInt",(Remote) bi);
System.out.println("services bound");
//}
}
}
My client
package BIConsulting.java;
import java.rmi.Naming;
public class Bclient
{
public static void main(String args[]) throws Exception{
if (args.length != 1)
{
System.out.println
("Syntax - PowerServiceClient host");
System.exit(1);
}
// Assign security manager
if (System.getSecurityManager() == null)
{
System.setSecurityManager
(new RMISecurityManager());
}
// Call registry for PowerService
BInt service = (BInt) Naming.lookup
("rmi://" + "sv-bic-0001" + "/BInt");
System.out.println("number is"+service.exec());
}
}
- 01-28-2009, 12:03 PM #2
Member
- Join Date
- Jan 2009
- Posts
- 2
- Rep Power
- 0
Similar Threads
-
Datagram Client and Server, client timer question
By saru88 in forum NetworkingReplies: 1Last Post: 10-05-2008, 03:12 PM -
Problem while running web service client
By krsv36 in forum Other IDEsReplies: 0Last Post: 05-15-2008, 05:12 PM -
When to use –client and -server option while running a java program
By Java Tip in forum java.langReplies: 0Last Post: 04-04-2008, 02:49 PM -
Identify Client in Socket Client Server Application
By masadjie in forum NetworkingReplies: 1Last Post: 12-20-2007, 09:18 AM -
Problems in running client class
By ai_2007 in forum Advanced JavaReplies: 0Last Post: 06-30-2007, 02:57 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks