简体   繁体   English

具有.java而不是.class文件的Netbeans Jar文件

[英]Netbeans Jar file with .java, not .class files

I'm trying to make a jar file through Netbeans, I can use the Clean & Build option and a new jar file will be made in my project directory. 我正在尝试通过Netbeans创建一个jar文件,可以使用Clean&Build选项,然后在我的项目目录中创建一个新的jar文件。 However I need to submit these jar files for homework assignments and they need to have the .java source files in them, not the .class files. 但是,我需要提交这些jar文件进行作业分配,并且它们中需要包含.java源文件,而不是.class文件。 My classmates generally use eclipse and have no problem, but I have not been able to find a solution in Netbeans. 我的同学通常使用eclipse并没有问题,但是我无法在Netbeans中找到解决方案。

I am using Netbeans 8.2 with Java 1.8.0_161. 我正在将Netbeans 8.2与Java 1.8.0_161一起使用。

Any help would be greatly appreciated! 任何帮助将不胜感激!

I just need to submit a jar file that will execute the program I just created that uses .java files instead of the .class files. 我只需要提交一个jar文件即可执行我刚刚创建的程序,该程序使用.java文件而不是.class文件。 The .class files in the jar are just jibberish to the grader. 罐子中的.class文件对平地机来说简直是杂乱无章。

Doesn't make sense. 没道理 In order to execute the JAR, you need the .class files, that's what gets executed. 为了执行JAR,您需要.class文件,即要执行的文件。

I would go back to your lecture and clarify what they mean 我会回到您的演讲中,弄清楚它们的含义

If you need to "also" include the .java files, then you can do the following: 如果需要“同时”包含.java文件,则可以执行以下操作:

Right click on the project node, select "Properties" from the popup menu 右键单击项目节点,从弹出菜单中选择“属性”

属性弹出

From the properties dialog, got to "Build | Packaging" 在属性对话框中,转到“构建|包装”

属性对话框

Change the "Exclude From JAR File" to remove the **/*.java from the available list of options. 更改“从JAR文件中排除”以从可用选项列表中删除**/*.java This should now include the .java files in the generated JAR 现在,这应在生成的JAR中包含.java文件

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

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