Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to make a specify client

 
filson sun
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have make a Constructor to make the user to have a specify program , but I do not know how to make the specify class that contains the user's configuration info to be the *.java
file (with the java language). who can help me ,Thank you !
 
Henry Wong
author
Marshal
Pie
Posts: 21385
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please elaborate? I am thinking there is a translation problem here, because I can't understand what you are asking.


And BTW, welcome to the JavaRanch.

Henry
 
filson sun
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:Can you please elaborate? I am thinking there is a translation problem here, because I can't understand what you are asking.


And BTW, welcome to the JavaRanch.

Henry


Thank you for paying attention to my question. My problem is that I am making a C/S program ,then I want to make the Client program with the configuration that let the user to fill it.
the Class is
"Class ClientFrame{
public ClientFrame(String hostIp, String hostPort){
........
}
}"
where,I want to save the specify instance of the ClientFrame ,then I can make it to the client user ,and he or she can use the *.java or *.jar to connect the host user computer.
But, I do not know how to save the specify instance of the ClientFrame ,and save it like the *.java or *.jar.
 
Henry Wong
author
Marshal
Pie
Posts: 21385
84
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
filson sun wrote:
where,I want to save the specify instance of the ClientFrame ,then I can make it to the client user ,and he or she can use the *.java or *.jar to connect the host user computer.
But, I do not know how to save the specify instance of the ClientFrame ,and save it like the *.java or *.jar.


To directly answer your question. You can pre-instantiate the objects that you want, and serialize them to a file. Then your program can simply derserialized the instances from those files.

However, I am guessing that this is *not* optimal. In your description, you sound like you want to set configurations. It might be a better idea to simply create configuration files, in any format that you want; and during application start up, load the configuration files, to instantiate the objects that you need.

Henry
 
filson sun
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry Wong wrote:
filson sun wrote:
where,I want to save the specify instance of the ClientFrame ,then I can make it to the client user ,and he or she can use the *.java or *.jar to connect the host user computer.
But, I do not know how to save the specify instance of the ClientFrame ,and save it like the *.java or *.jar.


To directly answer your question. You can pre-instantiate the objects that you want, and serialize them to a file. Then your program can simply derserialized the instances from those files.

However, I am guessing that this is *not* optimal. In your description, you sound like you want to set configurations. It might be a better idea to simply create configuration files, in any format that you want; and during application start up, load the configuration files, to instantiate the objects that you need.

Henry



Thank you! I will use your second idea
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic