Java “无法访问 jarfile”窗口命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19518329/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
"Unable to access jarfile" window command
提问by lisa
I am trying to create a .jar-file. Using Eclipse i generated a jar-file but it is not working the way i want.
我正在尝试创建一个 .jar 文件。使用 Eclipse 我生成了一个 jar 文件,但它没有按我想要的方式工作。
So i searched on the web and i found a solution:
于是上网查了一下,找到了解决办法:
create a file from the window command!!!
I tried bu its still not working although a made everything! :(
我试过了,但它仍然无法正常工作,尽管一切都做了!:(
When i run from the command i receive the following error:
当我从命令运行时,我收到以下错误:
Hier the content Manifest.txt:
Hier 内容 Manifest.txt:
Main-Class: main.testclass
Class-Path: lib/dom4j-1.5.jar lib/jdom.jar lib/xmlbeans-2.4.0.jar lib/ooxml-schemas-1.0.jar
sample.jar is the jar file i want to create , the Manifest.txt contains the dependencies for my class.
sample.jar 是我要创建的 jar 文件,Manifest.txt 包含我的类的依赖项。
Can someone please tell me what i am doing wrong?
有人可以告诉我我做错了什么吗?
Thanks you!
谢谢!
PS: I am using windwo xp
PS:我使用的是windwo xp
回答by Shaban Mousa
Are you sure that you run cmd as administrator ?
您确定以管理员身份运行 cmd 吗?
r-click on cmd and choose run as administrator.
右键单击 cmd 并选择以管理员身份运行。
回答by Reimeus
Use the jar command for creating JARs - The java -jar
syntax is for running JAR files
使用 jar 命令创建 JAR -java -jar
语法用于运行 JAR 文件
jar -cf sample.jar Manifest.txt /path/to/*.class
where /path/to
is the path to the class files contained in sample.jar
其中/path/to
包含的类文件的路径在哪里sample.jar