jQuery in Action, 2nd edition*
The moose likes Sockets and Internet Protocols and the fly likes how to net Send from my java code although  receiver has disable it Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "how to net Send from my java code although  receiver has disable it" Watch "how to net Send from my java code although  receiver has disable it" New topic
Author

how to net Send from my java code although receiver has disable it

ganesh pol
Ranch Hand

Joined: Apr 29, 2005
Posts: 151
friends i have modified one code it enables to the user to send message
continuously
but if receiver ignores me from network then my code does not work
how to send messages although user has disable my machine
code is as bellow


import java.io.*;
public class netSend extends Thread {

private String userName=" ";
private String message=" ";

public void run()
{
Runtime r=Runtime.getRuntime();
Process p=null;
try
{
for(int i=0;i<=1000;i++)
{
String user=this.getUserName();
String message=this.getMessage();
String command="net send "+user+ " "+message;
System.out.println("username is "+user+" message is "+message);

p=r.exec(command);//r.exec returns process Object
//p.waitFor();
Thread.sleep(5000);//causes current thread to sleep for 5 seconds
}
}
catch(Exception e)
{
System.out.println(e);
}
}

protected void setUserName(String userName){
this.userName=userName;
}

protected String getUserName(){
return userName;
}

protected void setMessage(String message){
this.message=message;
}

protected String getMessage(){
return message;
}

public static void main(String args[]) {


netSend t=new netSend();
t.setUserName(args[0]);
t.setMessage(args[1]);
t.run();

}
}

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to net Send from my java code although receiver has disable it
 
Similar Threads
Runtime.exec() file problem
Problem with running a program from Java file
how to send message from Command prompt to the user in network and who ignore me
An urgent problem with Runtime API
Exception in thread "AWT-EventQueue-0" java.lang.NoSuchMethodError: