问一个关于jar的问题(急!!!)

programergirl 2003-09-15 01:38:23
在我现在做的程序中,文档中关于jar文件是这样写的:When you submit your assignment, each part (client and server)

must be executable using a command of this exact form:

java -jar <path_and_filename> [<mode>]
Your programs must not require use of command line arguments other than the single mode flag, which must be supported. Your programs must not require use of command line property specifications. All configuration must be done via a GUI, and must be persistent between runs of the program. Such configuration information must be stored in a file called suncertify.properties which must be located in the current working directory.
The mode flag must be either "server", indicating the server program must run, "alone", indicating

standalone mode, or left out entirely, in which case the network client and gui must run.

我对jar文件不太熟,这个是怎麽实现的?那个suncertify.properties怎麽写呀?
还有,平时做关于RMI的程序时,client是连接本地server还是远端server一般是在用java命令指定。如果args.length==0则连接本地server;否则连接远端server,ip则在args[0]中。可在这种情况下,mode为"alone"则连接本地server;没有mode则只启动client,此时显然只有在GUI中输入ip,这样怎麽编程呢?
...全文
66 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
programergirl 2003-09-15
  • 打赏
  • 举报
回复
在平时写关于RMI程序时,不会用jar,都是直接用java执行class文件,因此客户端程序一般main方法时这样写:public static void main(String[] args) {
RMIClient rc = null;

if (args.length == 0) {
rc = new RMIClient("localhost");
}
else {
rc = new RMIClient(args[0]);

}
}

这样运行时如果用java RMIClient 则表示server在本地,若用java RMIClient 202.115.48.148 则表示server在202.115.48.148。
而在这个程序中可以改为在开始用JOptionPane.showInputDialog()由用户输入地址(ip或“localhost”)。但像文档中这样要求用java -jar <path_and_filename> [<mode>]的话,当用java -jar scjd2.jar alone时,显然不会让那个JOptionPane.showInputDialog()启动起来再判断server在哪里。那这样怎麽编程呢?

62,615

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧