java 解压缩 tar.gz 文件时出现问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16381917/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 22:49:28  来源:igfitidea点击:

Issues uncompressing a tar.gz file

javagziptarcompression

提问by Andy

I have been trying to uncompress the following file:

我一直在尝试解压缩以下文件:

sudo wget http://download.oracle.com/otn-pub/java/jdk/7u21-b11/jdk-7u21-linux-x64.tar.gz

with the following:

具有以下内容:

sudo tar zxvf jdk-7u21-linux-x64.tar.gz -C /usr/lib/jvm/

I am getting this error

我收到此错误

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now

I am using an Amazon Linux instances. By default jre is installed instead of the jdk, which I need to be able to run jboss. I would install the jdk using yum, but unfortunately it doesn't seem to be possible. Issue I am having is that it doesn't make sense why its not working if I am doing everything right from what I have been able to discern. I have downloaded two different versions just to be sure its not just corrupted files. Any help figuring this out would be greatly appreciated!

我正在使用 Amazon Linux 实例。默认情况下安装 jre 而不是 jdk,我需要能够运行 jboss。我会使用 安装 jdk yum,但不幸的是它似乎不可能。我遇到的问题是,如果我按照我能够辨别的方式做所有事情,为什么它不起作用是没有意义的。我已经下载了两个不同的版本,以确保它不仅仅是损坏的文件。任何帮助解决这个问题将不胜感激!

回答by Louie S

I know this thread is old, but I figured someone might be able to use this information when searching the web for why they can't unzip their JDK distros on raspberrypi

我知道这个帖子很旧,但我认为有人在搜索网络时可能能够使用这些信息,了解为什么他们无法在 raspberrypi 上解压缩他们的 JDK 发行版

If you pass these parameters to wget it will also accept the policy.

如果您将这些参数传递给 wget,它也会接受该策略。

--no-cookies --header "Cookie: oraclelicense=accept-securebackup-cookie"

回答by j883376

The reason the file isn't extracting properly is because the download pageis setting a cookie when you accept the license agreement. If you don't have the session cookie when attempting to download the file, it redirects you to an HTML page that tells you to accept the agreement first. If you open the .tar.gz that you're getting from wget, you'll see that it's an HTML file since it's not getting said cookie.

文件未正确提取的原因是下载页面在您接受许可协议时设置了 cookie。如果您在尝试下载文件时没有会话 cookie,它会将您重定向到一个 HTML 页面,该页面告诉您首先接受协议。如果您打开从中获取的 .tar.gz wget,您会看到它是一个 HTML 文件,因为它没有得到上述 cookie。

The easiest way to solve it is to download the file first, using your web browser, and then upload it to your web server.

解决此问题的最简单方法是先使用 Web 浏览器下载文件,然后将其上传到 Web 服务器。

回答by iamct

j883376 answer is right.But The easiest way to solve it is to download the file first, using your web browser, and then copy the download url then wget it useing your server.

j883376 回答是对的。但解决它的最简单方法是先使用您的网络浏览器下载文件,然后复制下载 url,然后使用您的服务器 wget 。