PDA

View Full Version : [SOLVED] problem with java intallation



dannydud
February 15th, 2011, 07:42 PM
Hi,
I am very new to linux.I want to run my java programs in ubuntu.I hav ubuntu 9.10...
I typed the command

sudo apt-get install openjdk-6-jdk

to download and install java.Then i wrote a simple hello program in editor and saved it as .java file.Then when i typed

javac hello.java

It says
The program 'javac' can be found in the following packages:
* openjdk-6-jdk
* ecj
* gcj-4.4-jdk
* gcj-4.3
* jikes-classpath
* jikes-kaffe
* kaffe
* sun-java6-jdk
Try: sudo apt-get install <selected package>
javac: command not found

How can i make java program run in my system.Pls heip me out to fix the problem..

Mariane
February 16th, 2011, 03:27 AM
Have you tried:

javac ./hello.java

?

Mariane

dannydud
February 16th, 2011, 09:07 PM
Yes i hav tried but it still says

The program 'javac' can be found in the following packages:
* openjdk-6-jdk
* ecj
* gcj-4.4-jdk
* gcj-4.3
* jikes-classpath
* jikes-kaffe
* kaffe
* sun-java6-jdk
Try: sudo apt-get install <selected package>
javac: command not found

Do i hav to install openjdk... again r do i hav to install anything else to make the programs work...?

lykeion
February 17th, 2011, 01:20 PM
Try to update java alternatives. To list available alternatives:

update-java-alternatives -l
Then set alternative to OpenJDK:

sudo update-java-alternatives -s java-6-openjdk
This should update path to javac, test with:

which javac

gmargo
February 17th, 2011, 04:54 PM
Looks like you do not have openjdk-6-jdk installed. Double check with:


$ dpkg --get-selections | grep jdk
$ dpkg -L openjdk-6-jdk

dannydud
February 18th, 2011, 05:05 PM
HI..

when i executed
sudo update-java-alternatives -s java-6-openjdk

it gave many update alternative error..

then when i executed
dpkg -L openjdk-6-jdk

it said
Package `openjdk-6-jdk' is not installed.

I guess java is not installed properly...i vil try installing it once again..

if i execute the command
sudo apt-get install openjdk-6-jdk

java pakage vil be installed know?coz i did it this way last time..after that do i hav set any classpath to execute java programs..?can anyone pls give me steps to install n execute java programs...thanks in advance...

lykeion
February 18th, 2011, 07:26 PM
You don't seem to have any JDK package installed. To install a JDK you could either start Synaptic or Ubuntu Software Center and search after "openjdk-6-jdk" or install directly in a terminal with this command:
sudo apt-get install openjdk-6-jdk
With that installed you should be able to compile java source with javac command. If that doesn't help could you please paste any errors you get when trying to install (and please do enclose error output in code tags using the # button).

dannydud
February 20th, 2011, 01:17 PM
Hi...
Thanks everyone.Java got installed properly & now its working fine.

dannydud
February 21st, 2011, 12:53 PM
Hi..
I newly installed ubuntu to my laptop.when i tried to install java by the command


sudo apt-get install openjdk-6-jdkit worked fine 4 my desktop but i am getting error in my laptop..the errors r as below

#Reading package lists... Done
#Building dependency tree
#Reading state information... Done
#You might want to run 'apt-get -f install' to correct these:
#The following packages have unmet dependencies:
#openjdk-6-jdk : Depends: openjdk-6-jre (>= 6b20-1.9.5-0ubuntu1) but it is not going to be installed
# Recommends: libxt-dev but it is not going to be installed
#sun-java6-jre : Depends: sun-java6-bin (>= 6.22-0ubuntu1~10.10) but it is not going to be installed or
# ia32-sun-java6-bin (>= 6.22-0ubuntu1~10.10) but it is not installable
# Recommends: gsfonts-x11 but it is not going to be installed
#E: Unmet dependencies. Try 'apt-get -f install' with no packages (or specify a solution).

Then i tried


apt-get -f installThen it says

#E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
#E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?

I am the only user of my system..Then when i said "yes" in command line i get continous

y
y
y
y
.
.
.


So how can i slove this problem..Pls help..

Dutch70
February 21st, 2011, 01:35 PM
Oops double post, check the next one.

Dutch70
February 21st, 2011, 01:40 PM
You have to put "sudo" in front of the command to be root.


sudo apt-get -f install

But I'm curious...
Why don't you just go to software center & install the Ubuntu restricted extras?

dannydud
February 21st, 2011, 06:28 PM
Hi..
Thanks for the help..The code

sudo apt-get -f installworked..
now java is working fine..Thanks again..

Dutch70
February 22nd, 2011, 01:29 AM
Hi..
Thanks for the help..The code

sudo apt-get -f installworked..
now java is working fine..Thanks again..


You're welcome, glad it worked for you.
So this is solved?