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

programergirl 2003-09-15 01:49:20
在我现在做的程序中,文档中关于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,这样怎麽编程呢?
...全文
53 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
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在哪里。那这样怎麽编程呢?
tianlinyi 2003-09-15
  • 打赏
  • 举报
回复
最多只给5分哦,MM还是比较小气啊,看都没什么人气,呵呵。。。

开个玩笑,祝开心!
tianlinyi 2003-09-15
  • 打赏
  • 举报
回复
其实jar文件就是把你的class都封装到一个jar文件中去压缩起来。这样就非常多的class时非常容易传输,因为小文件占的空间总是大,拷起来慢。

只要把你的jar文件加到你的classpath里面就可以访问jar文件中的class了
比如你的package是app.test
那么到app的上一级目录执行命令
jar cvf classes.jar app
你会发现当前目录多了一个jar文件,叫classes.jar,其中包含了package是app.test
把她加到classpath系统环境变量,这样就可以访问你的class了


-c 创建新的存档
-t 列出存档内容的列表
-x 展开存档中的命名的(或所有的〕文件
-u 更新已存在的存档
-v 生成详细输出到标准输出上
-f 指定存档文件名
-m 包含来自标明文件的标明信息
-0 只存储方式;未用ZIP压缩格式
-M 不产生所有项的清单(manifest〕文件
-i 为指定的jar文件产生索引信息
-C 改变到指定的目录,并且包含下列文件:

67,512

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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