使用Intellij 2016创建Jar - 没有主要清单属性 [英] Creating Jar with Intellij 2016 - No main manifest attribute

查看:457
本文介绍了使用Intellij 2016创建Jar - 没有主要清单属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在运行由Intellij创建的jar时,我得到没有主清单属性。我提取了jar并观察到另一个清单文件,而不是我在创建工件时指定的文件。



当我打开清单时IDE,它显示一切正确,但在创建jar后,我得到一个全新的清单文件。

 清单 - 版本:1.0 
主类:YoutubeList

我尝试了其他答案中的每个解决方案,但仍然没有做到正确。为什么创建一个简单的jar是Intellij的一项任务,它应该可以帮助开发人员!



已编辑



有时它不包含Jar中的.class文件导致无法找到或加载类

解决方案

我遇到了与maven build相同的问题。
当您从项目结构设置(ctrl + alt + shift + S)创建工件时,您必须更改清单目录:

 <项目文件夹> \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\资源

 <项目文件夹> \ src \\\\\\\\\\\\\\\\\\\\\\\\\\\ > 

我还使用了选项提取到目标JAR,它运行良好。


I am getting no main manifest attribute while running the jar create by Intellij. I extracted the jar and observed that there was another manifest file, not the one I had specified while creating artifact.

When I open manifest in IDE, it displays everything right but after creating jar I get a whole new manifest file.

Manifest-Version: 1.0
Main-Class: YoutubeList

I tried every solution from other answers and still not getting it right. Why creating a simple jar is hell of a task in Intellij, it was supposed to help developers!

Edited

And sometimes it does not include .class files in Jar which results in could not found or load class

解决方案

I was stucked with the same problem with maven build. When you are creating the artifact from project structure settings (ctrl+alt+shift+S), you have to change manifest directory:

<project folder>\src\main\java 

change java to resources

<project folder>\src\main\resources

I have also used the option extract to the target JAR, and it's working well.

这篇关于使用Intellij 2016创建Jar - 没有主要清单属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆