jar-用子目录构建,但仅包括.class文件

发布于 2025-02-12 01:06:12 字数 1311 浏览 1 评论 0原文

在Java中,我有一个项目,其目录结构看起来像这样,

.
├── enderbyteprograms
│   ├── consolecolours.class
│   ├── consolecolours.java
│   ├── consolegames
│   │   ├── games
│   │   │   ├── Game.class
│   │   │   ├── Game.java
│   │   │   ├── guess_the_number.class
│   │   │   ├── guess_the_number.java
│   │   │   ├── testgame.class
│   │   │   └── testgame.java
│   │   ├── Main.class
│   │   ├── Main.java
│   │   ├── shared.class
│   │   └── shared.java
│   ├── enderlib.class
│   └── enderlib.java
└── META-INF
    └── MANIFEST.mf

我正在尝试将其构建到一个只有.class文件的JAR。 JAR CVFM consolegames.jar Meta-inf/subest.mf enderByTeprograms/*。类仅包括类的顶级,导致程序抱怨没有找到入口点。使用jar cvfm consolegames.jar meta-inf/subest.mf enderbyTeprograms/*包括子目录,但还包括所有各种源文件,都会导致不必要的复杂性。如何构建仅包含 *.class文件但还包括目录层次结构的JAR文件? [JAR 11.0.15]

编辑1: 清单文件是

Manifest-Version: 1.0
Created-By: Enderbyte Programs
Main-Class: enderbyteprograms.consolegames.Main

In java I have a project whose directory structure looks like this

.
├── enderbyteprograms
│   ├── consolecolours.class
│   ├── consolecolours.java
│   ├── consolegames
│   │   ├── games
│   │   │   ├── Game.class
│   │   │   ├── Game.java
│   │   │   ├── guess_the_number.class
│   │   │   ├── guess_the_number.java
│   │   │   ├── testgame.class
│   │   │   └── testgame.java
│   │   ├── Main.class
│   │   ├── Main.java
│   │   ├── shared.class
│   │   └── shared.java
│   ├── enderlib.class
│   └── enderlib.java
└── META-INF
    └── MANIFEST.mf

I am trying to build this in to a jar that only has the .class files.
jar cvfm consolegames.jar META-INF/MANIFEST.mf enderbyteprograms/*.class only includes the top level of classes, causing the program to complain about not finding the entry point. Building with jar cvfm consolegames.jar META-INF/MANIFEST.mf enderbyteprograms/* includes the subdirectories but also includes all of the assorted source files leading to unnecessary complexity. How to build a jar file that only includes *.class files but also includes the directory hierarchy? [jar 11.0.15]

EDIT 1:
The manifest file is

Manifest-Version: 1.0
Created-By: Enderbyte Programs
Main-Class: enderbyteprograms.consolegames.Main

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

各空 2025-02-19 01:06:12

检查您的anist.mf是否具有属性主类,如果不添加此属性如下 -

主级:com.xyz.mainclass

Check if your MANIFEST.mf has attribute Main-Class, if not add this attribute as below -

Main-Class: com.xyz.MainClass

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文