我有一个IntelliJ IDEA Java项目,我想创建一个.jar文件
我选择Main Class并说出来自libary的JAR文件:
我有一个/ lib文件夹,其中包含我的应用程序使用的.jar文件。 我把它们添加到了项目中
如果我现在制作项目然后制作.jar文件,我会收到以下错误消息(不创建.jar文件,应用程序可以正常工作。
Error:Internal error: (java.util.zip.ZipException) invalid entry crc-32 (expected 0x5a5ec5c7 but got 0x16e4e973)
java.util.zip.ZipException: invalid entry crc-32 (expected 0x5a5ec5c7 but got 0x16e4e973)
at java.util.zip.ZipOutputStream.closeEntry(ZipOutputStream.java:296)
at java.util.zip.ZipOutputStream.finish(ZipOutputStream.java:361)
at java.util.zip.DeflaterOutputStream.close(DeflaterOutputStream.java:238)
at java.util.zip.ZipOutputStream.close(ZipOutputStream.java:378)
at org.jetbrains.jps.incremental.artifacts.impl.JarsBuilder.buildJar(JarsBuilder.java:212)
at org.jetbrains.jps.incremental.artifacts.impl.JarsBuilder.buildJars(JarsBuilder.java:88)
at org.jetbrains.jps.incremental.artifacts.IncArtifactBuilder.build(IncArtifactBuilder.java:166)
at org.jetbrains.jps.incremental.artifacts.IncArtifactBuilder.build(IncArtifactBuilder.java:50)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTarget(IncProjectBuilder.java:906)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:887)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:945)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:840)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:663)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:370)
at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:191)
at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:137)
at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:293)
at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:124)
at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler$1.run(BuildMain.java:242)
at org.jetbrains.jps.service.impl.SharedThreadPoolImpl$1.run(SharedThreadPoolImpl.java:41)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
答案 0 :(得分:0)
尝试制作工件。在Intellij 14.1.3中:
档案 - >项目结构 - >文物 - > (红色)加号 - > JAR
来自"可用元素"选择您的编译输出文件夹。在名为"' swingDemo'编译输出"
如果您有依赖项(比如我将gson:2.3.1添加到我的jar中),请将它们下载到您的/ lib文件夹中并使用(蓝色)加号添加它们 - >提取目录 - >从/ lib文件夹中选择了依赖项。
这基本上会将你的依赖关系放到一个JAR中。