java JAR 文件没有打开(用 winRAR 打开)?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/4702107/
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
The JAR file not open(it open with the winRAR)?
提问by Tofiq
I'm working with the netbeans and I create a jar file, but it not opened with the java. When I try to open it opened with the winRAR program. This is the MainClass code:
我正在使用 netbeans 并创建了一个 jar 文件,但它没有使用 java 打开。当我尝试打开它时,它是用 winRAR 程序打开的。这是主类代码:
public class MainClass {
public static void main(String arg[]){
Ludec cal=new Ludec();
cal.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
cal.setSize( 314, 380 );
cal.setLocation(600,150);
cal.setVisible( true );
}
}
It run in the cmd by this command:
java -jar "C:\Users\Tofiq\Documents\NetBeansProjects\JavaApplication1\dist\JavaApplication1.jar"
but not run by clicking and its error:
它通过以下命令在 cmd 中运行: java -jar "C:\Users\Tofiq\Documents\NetBeansProjects\JavaApplication1\dist\JavaApplication1.jar" 但不是通过单击运行,其错误:
回答by a1ex07
Jar is an archive(Java ARchive). When you install winRar it asks you for file extension association (by default it includes .jar files as well). You can later change this association in many ways, for example : Right click on any .jar file, 'Open With'-> 'Choose default program'->choose a program you want to use to open .jar file(don't forget to check 'Always use this program to open this kind of file').
Jar 是一个存档(Java ARchive)。当您安装 winRar 时,它会要求您提供文件扩展名关联(默认情况下它还包括 .jar 文件)。稍后您可以通过多种方式更改此关联,例如:右键单击任何 .jar 文件,“打开方式”->“选择默认程序”->选择要用于打开 .jar 文件的程序(不要忘记选中“始终使用此程序打开此类文件”)。
回答by a1ex07
Just run this batch code:
只需运行此批处理代码:
assoc .jar=jarfile
ftype jarfile=jarfile="<insert JRE bin directory>javaw.exe" -jar "%1" %*
This will associate .jar
files with the javaw
executable which is used to run .jar files
这会将.jar
文件与javaw
用于运行 .jar 文件的可执行文件相关联
回答by bestsss
java -jar "C:\Users\Tofiq\Documents\NetBeansProjects\JavaApplication1\dist\JavaApplication1.jar" but not run by clicking and its error:
java -jar "C:\Users\Tofiq\Documents\NetBeansProjects\JavaApplication1\dist\JavaApplication1.jar" 但不能通过单击运行及其错误:
For -jar to work you need the MANIFEST file.
要使 -jar 工作,您需要 MANIFEST 文件。
回答by dm76
probably because you installed winrar after installing netbeans and java, so that the .jar extension has been re-associated with winrar.
可能是因为你安装了netbeans和java之后安装了winrar,所以.jar扩展名已经重新关联到winrar了。
you'll need to modify the file extension .jar to be associated with the JVM
您需要修改文件扩展名 .jar 以与 JVM 关联