Jump to content

Welcome to Geeks to Go - Register now for FREE

Need help with your computer or device? Want to learn new tech skills? You're in the right place!
Geeks to Go is a friendly community of tech experts who can solve any problem you have. Just create a free account and post your question. Our volunteers will reply quickly and guide you through the steps. Don't let tech troubles stop you. Join Geeks to Go now and get the support you need!

How it Works Create Account
Photo

how to run chat application on multiple systems


  • Please log in to reply

#1
jayeth

jayeth

    Member

  • Member
  • PipPip
  • 18 posts
Hi guys,
I have a pure java chat application that I want to run it on multiple system ie., in one server and multiple client machine...i tried running in a single system(first computer) having it as both the server and the client, it worked...
when i tried to run this on 2nd computer through the ip address of the first computer ie., without moving the files to 2nd computer, the program didn't run.
(i'm using the batch file to run the java program)

...the command prompt says
"Cmd.exe does not support UNC names as the current directory"
How do i solve this?
  • 0

Advertisements


#2
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
UNC names error : http://support.microsoft.com/kb/156276
  • 0

#3
jayeth

jayeth

    Member

  • Topic Starter
  • Member
  • PipPip
  • 18 posts
Thought so...but is there a better solution for this?...cos u know, it's not practically possible for me to change the registry of all the computers in the intranet...i guess these r the problems i got go with if i had to use java :) ...Do u think i should rather convert it to JSP? :)
  • 0

#4
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
I forgot. Can you edit the program itself?
It might help to use the intranet IPs of the computers
  • 0

#5
jayeth

jayeth

    Member

  • Topic Starter
  • Member
  • PipPip
  • 18 posts
i tried to convert the code but it's gonna take a lot of time...is there any code for reading/writing registry key using java?..
i think that shud help..
  • 0

#6
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
This looks promising but complicated:
http://sourceforge.n...s/jregistrykey/
But if you don't understand it's probably just a way to create a new problem.
I certainly don't know enough about java to properly help you with that.
  • 0

#7
jayeth

jayeth

    Member

  • Topic Starter
  • Member
  • PipPip
  • 18 posts
Hi...
Thanxs a ton for your efforts :) ...but actually i just need a few lines of code or atleast a single program for accessing that...if not deep, u are atleast familiar with java, right?...if so can u help me with the below code?
import java.io.*;   
	
public class RegQuery {   
	
private static final String REGQUERY_UTIL = "reg query ";   
private static final String REGSTR_TOKEN = "REG_SZ";   
private static final String COMPUTER_WINDOWS_FAVORITES_FOLDER = REGQUERY_UTIL +   
"\"HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders\" /v Favorites";   
	
public static String getCurrentPCFavorites()   
{   
try {   
Process process = Runtime.getRuntime().exec(COMPUTER_WINDOWS_FAVORITES_FOLDER);   
StreamReader reader = new StreamReader(process.getInputStream());   
reader.start();   
process.waitFor();   
reader.join();   
String result = reader.getResult();   
int p = result.indexOf(REGSTR_TOKEN);   
if (p == -1)   
return null;   
return result.substring(p + REGSTR_TOKEN.length()).trim();   
}   
catch (Exception e) {   
return null;   
}   
}   
	
static class StreamReader extends Thread {   
private InputStream is;   
private StringWriter sw;   
	
StreamReader(InputStream is) {   
this.is = is;   
sw = new StringWriter();   
}   
	
public void run() {   
try {   
int c;   
while ((c = is.read()) != -1)   
sw.write(c);   
}   
catch (IOException e) {; }   
}   
	
String getResult() {   
return sw.toString();   
}   
}   
	
public static void main(String s[]) {   
System.out.println("Personal directory : " + getCurrentPCFavorites());   
}   
}

now, this code works fine for reading from registry and displaying the location of the favorite folder...i want this program to write to registry..i tried using changing the value of REQUERY_UTIL to add reg...but that didn't work...can u help me?

Edited by jayeth, 18 March 2009 - 03:27 AM.

  • 0

#8
Metallica

Metallica

    Spyware Veteran

  • GeekU Moderator
  • 33,101 posts
The command line to change or add a registry value is "reg add"

So that would change the code to:
private static final String REGQUERY_UTIL = "reg add ";

  • 0

#9
jayeth

jayeth

    Member

  • Topic Starter
  • Member
  • PipPip
  • 18 posts
Hi,
i tried...but it's not working...here's the code...
import java.io.*;
import java.lang.*;
	
public class RegQuery {   
	
private static final String REGQUERY_UTIL = "reg add ";   
private static final String REGSTR_TOKEN = "REG_DWORD";   
private static final String COMPUTER_WINDOWS_FAVORITES_FOLDER = REGQUERY_UTIL +   
"\"HKCU\\Software\\Microsoft\\Command Processor\" /v DisableUNCCheck /t REG_DWORD /d 0×00000001 /f";   
	
public static String getCurrentPCFavorites()   
{   
try {   
Process process = Runtime.getRuntime().exec(COMPUTER_WINDOWS_FAVORITES_FOLDER);   
StreamReader reader = new StreamReader(process.getInputStream());   
reader.start();   
process.waitFor();   
reader.join();   
String result = reader.getResult();   
int p = result.indexOf(REGSTR_TOKEN);   
if (p == -1)   
return null;   
return result.substring(p + REGSTR_TOKEN.length()).trim();   
}   
catch (Exception e) {   
String s="error";
return s;
}   
}   
	
static class StreamReader extends Thread {   
private InputStream is;   
private StringWriter sw;   
	
StreamReader(InputStream is) {   
this.is = is;   
sw = new StringWriter();   
}   
	
public void run() {   
try {   
int c;   
while ((c = is.read()) != -1)   
sw.write(c);   
}   
catch (IOException e) {; }   
}   
	
String getResult() {   
return sw.toString();   
}   
}   
	
public static void main(String s[]) {   
System.out.println("Personal directory : " + getCurrentPCFavorites());   
}   
}

  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP