File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Sending class file through a network Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Sending class file through a network" Watch "Sending class file through a network" New topic
Author

Sending class file through a network

Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Hello Friends,

There is a client server architecture already created..
now, I have a .class file and .jar file and I require these to send from the client to the server and store on the server.. I have Implemented something using Class ClassLoader..but the solution is not workin and is completely messed up..

how can I send..?please give an overview to do this..?

Also one more question...........Is class File an Array of bytes(byte [])..??

Can anyone please give their suggestions on the above problem.Thank you in advance.

Regards,
Hardik.S.Raja
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8900
    
    8

Originally posted by Hardik Raja:
I have a .class file and .jar file and I require these to send from the client to the server and store on the server..


Is the server loading the class and doing some task with it? If it is simply storing it, you don't have to load it with a class loader. Just write it to a file.

Originally posted by Hardik Raja:

Also one more question...........Is class File an Array of bytes(byte [])..??


All files are arrays of bytes.


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Is the server loading the class and doing some task with it?


Yes after the .class file and .jar file is transferred to the server...the server needs to instantiate that class ( for instantiating it also requires the .jar file)
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
hello friends...

I have figured out how to send a .Class file and load it on the server..

But what to do, for transfering the (Executable) .Jar file from the client to server....any suggestions are welcome..Thanks in advance...

Regards,
Hardik.S.Raja
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Hello friends and moderators,

I know all people replying in this forum are giving their precious time to help forum users and its not proper to ask them to solve queries immediately...but I am stuck up at a very minute spot..so just requesting to reply...

I have posted the query, since 1 and 1/2 days back but yet to get any help
Please friends reply to my query.

To Bartender....IS MY TOPIC PLACED IN THE RIGHT FORUM...IF ITS NOT EQUIVALENT PLEASE MOVE THIS THREAD TO AN APPROPIATE ONE........thank you..

regards,
Hardik Raja
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41815
    
  62
Why don't you extend your classloader so that it can handle jar files as well as class files? Tell us what do you have so far in detail and how it does or does not work.

Or is the problem the transferring of the file(s) to the server? It's not quite clear from your posts.


Ping & DNS - my free Android networking tools app
Hardik Raja
Ranch Hand

Joined: Feb 07, 2006
Posts: 117
Hello Ulf Dittmer,

I am redefining my problem statement as per you said....

PROBLEM STATEMENT :

I have a Client - Server Architecture and I require to transfer a,(EXECUTABLE).jar file and a .class file( which uses above .JAR file )

I Dont know what to do for .JAR file..

But here is What I Have implemented for transferring .class file from client to server.






On the Server side I am able to receive this byte array,by using ClassLoader, I am Loading this class as follows




I am highlighting the part in which i am getting error..??

Please revert back if you have any other question..Thank you in advance.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41815
    
  62
I don't understand how this code transfers a class file over the network, or how it is supposed to instantiate it. Especially amazing to me is that somewhere in between the contents of the class file are converted to character data (by storing them in a StringBuffer), and it still works afterwards.

Be that as it may, I would use any standard method of transferring files (e.g. the ones mentioned here) to the server, and once the files (.class and .jar) are there, create a classloader that knows where to look for loose class files files, and which also knows how to look for class files inside of jar files.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sending class file through a network