|
|
|
|
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.
|
|

04-03-2008, 10:58 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 3
|
|
|
How to call the input value from different file?
I am doing a sever/client chat program. I wish to let the user to enter their entire name through input dialog and I want to use the name that entered by the user in client.java to be use in server.java so that it will shows "username connected to server". I wish to know how to get the username that entered by the user in client to be use in server. Hope anyone can answer me. Thanks.
|
|

04-03-2008, 11:11 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,568
|
|
|
You asking that how to pass a value from one class to the other? I've not clear your question pal.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

04-03-2008, 11:27 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 3
|
|
|
ya, exactly like wad u say. But the class is in different java file. Able to make it?
|
|

04-03-2008, 11:31 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,568
|
|
|
It's basis in Java. Even you have two Java files(as you say server.java and client.java) there is two classes. To access from one class to the other, in simple word, you need an object of a class in the others.
So create an object of server class in the client class and using that object call a function of a server class to check the username.
Is that clear.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|

04-03-2008, 11:34 AM
|
|
Member
|
|
Join Date: Apr 2008
Posts: 3
|
|
|
sorry, but i don't get u. Coz i m still new to java. Can u write me an example of code of how to make it? Thanks.
|
|

04-03-2008, 11:53 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 3,568
|
|
Ok, I'll explain it in simple way as follows.
public class Client{
String username;
// Get the user name through a GUI and set it to username
// Object for class Server
Server myServer = new Server();
myServer.isValid(username);
}
public class Server{
// Check that username is correct
public void isValid(String name){
// Check that user name is valid, and so do the process
}
}
Is that clear now, or need more explanations.
Actually if you don't know how those basis things done, please spend some time with Java fundamentals. If you don't know such things to do, how can you handle a server-client application.
In a such a project you have to do much more than this, it's not going to be easy for you pal 
__________________
Use an appropriate Subject. "Help, urgent!" isn't one. To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Has someone helped you? Then you can To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts. their helpful post.
Want to make your IDE the best? To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|
All times are GMT +3. The time now is 12:55 PM.
|
|
VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org