简体   繁体   English

尝试使用Eclipse创建可运行的jar文件时收到警告消息

[英]Getting warning message when trying to create a runnable jar file using eclipse

I am trying to create a Runnable Jar file for my java project. 我正在尝试为我的java项目创建一个Runnable Jar文件。 I am using Eclipse Kepler to do so but after creating the jar file i am getting some warning message from the Eclipse. 我正在使用Eclipse Kepler这样做,但是在创建jar文件后,我从Eclipse得到了一些警告消息。 I tried to find the answer on google but got nothing. 我试图在Google上找到答案,但一无所获。 I am not able to copy paste the error message which i received from the eclipse so i am attaching the screen shot of it. 我无法复制并粘贴我从日食中收到的错误消息,因此我附上了它的屏幕截图。

But i am able to use that jar file without any warning. 但是我能够在没有任何警告的情况下使用该jar文件。

警告按摩的屏幕截图

When Java (and hence Eclipse) compiles a .java file, it might work with no problems, or it might produce warnings or errors . 当Java(因此是Eclipse)编译.java文件时,它可能没有问题,或者可能产生警告错误 If you get errors then it means that the file couldn't be compiled: you have to fix the errors before you can run your program. 如果收到错误,则表示文件无法编译:必须先修复错误,然后才能运行程序。 But warnings are different: they let you know that you've done something suspicious that usually indicates a mistake, but since what you wrote was valid Java according to the syntax, the warnings didn't stop the compilation, and you'll be able to run your program. 但是警告是不同的:它们让您知道您做了可疑的操作(通常表示错误),但是由于您根据语法编写的内容是有效的Java,因此警告不会停止编译,您将能够运行程序。

If a file has errors in it, then there will be a red cross placed in the project explorer view, superimposed over the icon for the file. 如果文件中有错误,则在项目资源管理器视图中将有一个红色的十字标记,叠加在该文件的图标上。 There will also be red crosses down the right-hand side of the editor pane for that file, telling you where the errors are. 该文件的编辑器窗格右侧还会有红色的叉形,告诉您错误在哪里。

If there are warnings, then there will be a tiny yellow triangle instead, and also yellow triangles down the right-hand side of the editor pane. 如果有警告,则将显示一个小黄色三角形,并且在编辑器窗格的右侧下方也将出现黄色三角形。 But they're fairly inconspicuous, and you won't necessarily notice them unless you know to look for them. 但是它们相当不起眼,除非您知道要寻找它们,否则您不一定会注意到它们。

What's going on in your case is that you're building a runnable jar file out of a project that contains some warnings but no errors. 您的情况是,您正在从包含一些警告但没有错误的项目中构建可运行的jar文件。 What you're seeing is a list of files that have compiler warnings. 您将看到具有编译器警告的文件列表。 You can check this by going back to your project explorer pane and looking to see which files have yellow triangles. 您可以通过返回项目浏览器窗格并查看哪些文件带有黄色三角形来进行检查。 The reason you've noticed the warnings at this point is that you get hit with a big yellow triangle when you export to a jar file, rather than the tiny yellow triangles that were there before. 此时您注意到警告的原因是,导出到jar文件时会遇到一个大的黄色三角形,而不是之前存在的微小的黄色三角形。 The big yellow triangle is no more, or less, significant than the tiny yellow ones. 大的黄色三角形与小黄色的三角形没有太大或更少的重要性。

So you should expect your jar file to run, but you shouldn't think that means you can completely ignore the warnings. 因此,您应该期望jar文件能够运行,但是您不应该认为这意味着您可以完全忽略警告。 You will need to check each one carefully, and see whether the warnings are indicative of problems or not. 您将需要仔细检查每一个,并查看警告是否指示问题。 If you want to write good code, it's good to get into the habit of making sure that you eventually get rid of all the compiler warnings in your source. 如果要编写好的代码,最好养成确保最终摆脱源代码中所有编译器警告的习惯。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM