Results 1 to 2 of 2
  1. #1
    anukatoch is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

    Default 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());



    }
    }

  2. #2
    anukatoch is offline Member
    Join Date
    Jan 2009
    Posts
    2
    Rep Power
    0

Similar Threads

  1. Replies: 1
    Last Post: 10-05-2008, 04:12 PM
  2. Problem while running web service client
    By krsv36 in forum Other IDEs
    Replies: 0
    Last Post: 05-15-2008, 06:12 PM
  3. Replies: 0
    Last Post: 04-04-2008, 03:49 PM
  4. Identify Client in Socket Client Server Application
    By masadjie in forum Networking
    Replies: 1
    Last Post: 12-20-2007, 10:18 AM
  5. Problems in running client class
    By ai_2007 in forum Advanced Java
    Replies: 0
    Last Post: 06-30-2007, 03:57 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •