简体   繁体   English

创建JAR文件并在Raspberry PI上运行

[英]Creating a JAR file and running on Raspberry PI

This is a very common question and there are chances that this might be marked as Duplicate, but even after reviewing a lot of answers and posts from stackoverflow and other communities, the problem just doesn't solve. 这是一个非常常见的问题,并且有可能将其标记为重复,但即使在审查了stackoverflow和其他社区的大量答案和帖子后,问题也无法解决。

I have created a Project in my NetBeans IDE 7.3 and I Build the Project to get the JAR file by pressing SHIFT+F11. 我在NetBeans IDE 7.3中创建了一个项目,并通过按SHIFT + F11来构建项目来获取JAR文件。 The next step, I perform is through WinSCP I copy the JAR file from my Windows Machine to the directory (/home/pi) in Raspberry PI. 下一步,我执行的是通过WinSCP将JAR文件从我的Windows机器复制到Raspberry PI中的目录(/ home / pi)。 Now, I am in the directory in my Raspberry PI where the JAR file is present and in the terminal I run the command 现在,我在我的Raspberry PI目录中,其中存在JAR文件,在终端中我运行命令

java -jar ProjectFinal.jar

I get the error "Could not find or load main class". 我收到错误“无法找到或加载主类”。

The contents of my JAR are as shown below (in the form of directories): lib (contains all the libraries) META-INF (contains a MANIFEST.MF file and the contents looks fine) and the contents are shown below: 我的JAR的内容如下所示(以目录的形式):lib(包含所有库)META-INF(包含MANIFEST.MF文件,内容看起来很好),内容如下所示:

Manifest-Version: 1.0
Ant-Version: Apache Ant 1.8.4
Created-By: 1.7.0_17-b02 (Oracle Corporation)
Class-Path: lib/super-csv-2.1.0.jar
X-COMMENT: Main-Class will be added automatically by build
Main-Class: projectfinal.ProjectFinal**

and finally projectfinal (contains all the class files). 最后是projectfinal(包含所有类文件)。 I tried to change the contents of the MANIFEST.MF file by following this link . 我尝试通过以下链接更改MANIFEST.MF文件的内容。 But this couldn't help me either. 但这也无济于事。 Please suggest me any ideas that could get me out of this. 请建议我任何可以让我摆脱这种想法的想法。 It could be really helpful. 它可能真的很有帮助。 I can share the code if it is needed. 如果需要,我可以共享代码。 I am using JRE version 7. Any questions/inputs/ideas is deeply appreciated. 我正在使用JRE版本7.任何问题/输入/想法都非常感谢。

Please help. 请帮忙。

Thanks a lot in advance. 非常感谢提前。

I don't know about NetBeans but Eclipse IDE has an option to export into a "Runnable JAR File" instead of a normal JAR file. 我不了解NetBeans,但Eclipse IDE可以选择导出到“Runnable JAR File”而不是普通的JAR文件。
I had the same issue and it solved my problem. 我有同样的问题,它解决了我的问题。

If not then follow this: 如果没有,那么按照这个:

The text file must end with a new line or carriage return. 文本文件必须以新行或回车结束。 The last line will not be parsed properly if it does not end with a new line or carriage return. 如果不以新行或回车结束,则不会正确解析最后一行。

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

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