ubuntu装好java就进不去了,Ubuntu上的Java安装问题

Trying to install Java (JDK 6) on my new Ubuntu system and getting some bizarro errors. This is my first time ever using any flavor of Linux and so I'm sure it's a user issue (permissions or otherwise).

I downloaded the BIN file directly off Oracle's site (Java SE 6u23 for 64-bit Linux). This defaulted to downloading to /home/myUserName/Downloads.

From there I moved the file to /opt/java, which was a directory I created, because (as a Linux novice) that made sense to be the directory where Java should go.

I then ran the following 2 commands, per instruction I found online for running BINs:

chmod +x jdk-6u23-linux-x64.bin

sudo ./jdk-6u23-linux-x64.bin

Now, in my /opt/java directory I see both the BIN file and the jdk1.6.0_23 directory that seems to be intact upon inspection.

But, when I open a new terminal and run java -version, I get:

The program 'java' can be found in the following packages:

- gcj-4.4-jre-headless

- gcj-4.5-jre-headless

- openjdk-6-jre-headless

Try: sudo apt-get install

What is going on here?!?

(1) Was I wrong to try and make /opt/java my Java directory?

(2) Did I run the wrong commands?

(3) Is Java 1.6.0_23 even installed on my machine?

(4) What are all those gcj-xxx-headless targets?!?!

Thanks for any input!

解决方案

Was I wrong to try and make /opt/java my Java directory?

Not really. Many Java developers install multiple JDK installations and always use /opt/jdk1.6.0_23 or similar paths. The bin file you downloaded is not an installer, but merely an extractor. It does not install the java binaries into system folders like /bin.

I usually download the JDK and execute it from within my home folder and afterwards move it to /opt and performing an chown.

Did I run the wrong commands?

Not really. In case you wanted to install a separate JDK, you did it correctly. In case you wanted system integration, you would be better off to use the distribution-specific packages, such as the one installed via aptitude install sun-java6-jdk or alike.

The bin you downloaded is imho more flexible, since I can use it to install multiple verisons of Java on the same system. I know this is something you don't often do on Linux machines.

If you want to use the java binary on command line, you'd have to manually set up the PATH and JAVA_HOME environment variables. I think on Ubuntu that's /etc/environment or /etc/profile or something like that.

Is Java 1.6.0_23 even installed on my machine?

Not really. See above answers.

What are all those gcj-xxx-headless targets?!?

The GCJ is the Gnu Compiler for Java. Obviously, it includes a Java Development Kit and a Java Runtime Environment.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值