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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 17:58:28  来源:igfitidea点击:

"Unable to access jarfile" window command

javajarcommand

提问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:

当我从命令运行时,我收到以下错误:

enter image description here

在此处输入图片说明

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 -jarsyntax is for running JAR files

使用 jar 命令创建 JAR -java -jar语法用于运行 JAR 文件

jar -cf sample.jar Manifest.txt /path/to/*.class

where /path/tois the path to the class files contained in sample.jar

其中/path/to包含的类文件的路径在哪里sample.jar

回答by ZaoTaoBao

try to do it in this way! exportkind of fileselect what you wanna and destination

尝试这样做! 出口文件类型选择你想要的和目的地

Remember to leave in your documents or someplace like you have permissions!, if you aren't administrator.In the second picture is important select what you wanna have inside jar.

如果您不是管理员,请记住保留在您的文档中或像您有权限的地方!在第二张图片中选择您想要在 jar 中包含的内容很重要。