Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-31-2008, 07:50 PM
Member
 
Join Date: Mar 2008
Posts: 1
pushpik is on a distinguished road
distributed computing in java
Hi,
I am writing a distributed computing application for my project. I am receiving a java class file in byte stream from Client PC which i want to load in Current loader of server so that i can run any method present in received class. i want to load it in current loader because this received class is made by extending another Class which is present at server.

in the code bellow class received as byte is named PrimeNumberChecker and package name jdcclient. PrimeNumberChecker is made by extending Gthread which is present at server. I have made ByteCodeLoader which extends ClassLoader to load byte in loader. whats is wrong in the code

public static void main(String[] args) {
try {
ServerSocket serverSocket = new ServerSocket(9000);
System.out.println("Server listening on port 9000 for thread classes");

System.out.println("Waiting for connections.");
Socket client = serverSocket.accept();
System.out.println("Accepted a connection from: "+client.getInetAddress());

//Getting client classes in byteArray
DataInputStream dis = new DataInputStream(client.getInputStream());
int avail = dis.available();
System.out.println("Available = " + avail);
byte byteCode[] = new byte[avail];
dis.readFully(byteCode);

ByteCodeLoader loader = new ByteCodeLoader();
loader.setByteCode(byteCode);
Class getClass = loader.loadClass("jdcclient.PrimeNumberChecker", true);

dis.close();


//Getting Thread from client
ObjectInputStream ois = new ObjectInputStream(client.getInputStream());
GThread thr = (GThread) ois.readObject();

thr.start();

//System.out.println("OutPut is "+ output.intValue());
/*
ObjectOutputStream oos = new ObjectOutputStream(client.getOutputStream());
oos.writeObject(thr);

oos.flush();
oos.close();
*/
ois.close();
client.close();

} catch (Exception ex) {
ex.printStackTrace();
}
}
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Computing prime numbers in Java Java Tip java.lang 0 04-12-2008 09:39 PM
Computing the area of a triangle using Heron's Formula Java Tip java.lang 0 04-12-2008 09:39 PM
which is the best technology for distributed application. sujithc34 Advanced Java 1 02-05-2008 07:52 PM
Computing Fibonacci numbers recursively Java Tip Java Tips 0 01-22-2008 09:20 PM


All times are GMT +3. The time now is 12:57 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org