Error invalid or corrupt jarfile что делать

Invalid or corrupt jarfile

Как вообще надо создавать нормальные стандалон-приложения на java?

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

Скорее всего у тебя действительно повредился файл в процессе переноса.

Ладно, попробую перенести еще раз (как доберусь до компа с исходниками), хотя сомнительно что проблема в этом.

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

Jar-файл это просто ZIP-архив. Попробуй его разархивировать любым архиватором. Если получится — можно дальше думать. Если не получится — значит файл повреждён.

Фигасе, действительно обычный архив! 🙂 Открывается, там оказывается запихнуто все что надо и не надо из сорцов проекта. Файл вроде не поврежден, как я и подозревал.

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

Покажи вывод jar tf usergrid-launcher-1.0-SNAPSHOT.jar

Виндовая (знаю где я, не бейте :)) недоконсоль закрывается и не дает прочитать что там написано. Щас буду пробовать победить это и покажу.

«jar» не является внутренней или внешней командой, исполняемой программой или пакетным файлом.

jdk установи для начала

Хороший вопрос. Могу установить конечно, но зачем мне он на машине, где я хочу только запускать готовые приложения? Или Java-программы не будут работать на компах где есть только jre?

Будут, естественно. Но если вам нужно разрабатывать, вам нужен jdk. Почему вы удивляетесь тому, что у вас нет команды jar, если не установлен jdk?

Понял, ради этой команды сейчас качаю и установлю jdk последний. Хотя на этом компе я хотел только запустить программку, которую написал на другом, где она запускается (и где конечно и jre и jdk).

Источник

Corrupt jar file

I have created a jar file in windows 7 using eclipse. When I am trying to open the jar file it says invalid or corrupt jar file. Can anyone suggest me why the jar file is invalid?

12 Answers 12

In Eclispe, you need to export the project as Runnable JAR file instead of as JAR file to get a real executable JAR.

This regularly occurs when you change the extension on the JAR for ZIP, extract the zip content and make some modifications on files such as changing the MANIFEST.MF file which is a very common case, many times Eclipse doesn’t generate the MANIFEST file as we want, or maybe we would like to modify the CLASS-PATH or the MAIN-CLASS values of it.

The problem occurs when you zip back the folder.

A valid Runnable/Executable JAR has the next structure:

Once you’re done try execute it on the command line using:

When you use a zip tool to unpack, change files and zip again, normally the JAR structure changes to this structure which is incorrect, since another directory level is added on the top of the file system making it a corrupted file as is shown below:

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

The problem might be that there are more than 65536 files in your JAR: Why java complains about jar files with lots of entries? The fix is described in this question’s answer.

This is the common issue with «manifest» in the error? Yes it happens a lot, here’s a link: http://dev-answers.blogspot.com/2006/07/invalid-or-corrupt-jarfile.html

Using the ant task to create the manifest file on-the-fly gives you and entry like:

Creating the manifest file myself, with the bare essentials fixes the issue:

Notes:

Parsing of the Meta-inf file has been an issue that has come-up, been fixed and then come-up again for sun. See: Bug Id: 4991229. If you can work out if this bug exists in the your (or my) version of the Java SE you have more patience that me.

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

Also, make sure that the java version used at runtime is an equivalent or later version than the java used during compilation

As I just came across this topic I wanted to share the reason and solution why I got the message «invalid or corrupt jarfile»:

I had updated the version of the «maven-jar-plugin» in my pom.xml from 2.1 to 3.1.2. Everything still went fine and a jar file was built. But somehow it obviously wouldn’t run anymore.

As soon as i set the «maven-jar-plugin» version back to 2.1 again, the problem was gone.

It can be a typo int the MANIFEST.MF too, p.ex. Build-Date with two :

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

If the jar file has any extra bytes at the end, explorers like 7-Zip can open it, but it will be treated as corrupt. I use an online upload system that automatically adds a single extra LF character (‘\n’, 0x0a) to the end of every jar file. With such files, there are a variety solutions to run the file:

Источник

error invalid or corrupt jarfile

Файл manifest.mf

Структура проекта:

Error invalid or corrupt jarfile что делать. Смотреть фото Error invalid or corrupt jarfile что делать. Смотреть картинку Error invalid or corrupt jarfile что делать. Картинка про Error invalid or corrupt jarfile что делать. Фото Error invalid or corrupt jarfile что делать

1 ответ 1

В общем idea в не правильный каталог генерирует Manifest файл. Нужно его перекинуть в resources

Всё ещё ищете ответ? Посмотрите другие вопросы с метками java javafx или задайте свой вопрос.

Похожие

Для подписки на ленту скопируйте и вставьте эту ссылку в вашу программу для чтения RSS.

дизайн сайта / логотип © 2019 Stack Exchange Inc; пользовательское содержимое попадает под действие лицензии cc by-sa 4.0 с указанием ссылки на источник. rev 2019.11.15.35459

Comments

Copy link Quote reply

ccit-spence commented Apr 13, 2015

This comment has been minimized.

Copy link Quote reply

dsyer commented Apr 13, 2015

It depends on the pom (which you don’t show). Dockerfile ADD works relative to the Dockerfile, so for yours to work you need to copy the jar file to a «target» directory in «target/docker». The maven plugin allows you to do that with a element.

Dan’s technical ramblings

I was creating a Jar via the Java API’s and I couldn’t get it to run my main class:

Running it via the class path worked fine:

So now I knew it was something to do with the manifest file but it wasn’t being caused by

So after scratching my head for a while I tried comparing a working jar with the failing jar:

So don’t prefix the META-INF folder with a slash! Also note it is case sensitive!

3 thoughts on “ Error: Invalid or corrupt jarfile ”

It’s weird if Java API creates such invalid jars.

Thanks Dan! We had the 65535 jar limit problem and your blog pointed me in the right directions. Ultimately fixed by doing this:

Thank you! Good to know that it could be because of issues with the Manifest.

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Источник

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *