Run Java-Problem! [Solved]

Discussions Regarding Software

Moderator: Moderators

Run Java-Problem! [Solved]

Postby andreas_g » Thu Nov 05, 2009 16:40

I have a really annoying problem this java. The last summer, when i was "playing" with Java/Swing, I used to run my programs using the "javac" and "java" commands from konsole(I don't like IDEs :roll: )!!! And everything was fine.
Yesterday, I tried to run a simple program and I got this message. The link of the little pop-up window sent me to this site!!!!!
I had already tried to to reinstall java(1.6 version), but nothing happend. I Installed java(version 1.5).........nothing happend too. :cry: :cry: :cry:

What's going on??? ??? ???
What can I do??? ??? ????

A friend told me to change some configuration files of java, but I didn't understad!!!!

Now my java version is
Code: Select all
[email protected] ~/Desktop $ java -version
java version "1.6.0_16"
Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) Server VM (build 14.2-b01, mixed mode)

And I use Sabayon 5.0 KDE 32-bit.


Thanks in advance!!!
Last edited by andreas_g on Sat Nov 07, 2009 4:38, edited 1 time in total.
Sorry for my bad english!!!!!!!
andreas_g
Young Hen
 
Posts: 31
Joined: Sun Sep 14, 2008 0:43
Location: /home/andreas/greece

Re: Run Java-Problem!!!

Postby thecata » Thu Nov 05, 2009 18:36

For the record, I hate the way Gentoo (and implicitly, Sabayon) handle multiple JVMs. As far as I can tell, this is your problem as well. Here's how I fixed it:
1) make sure you have the "dev-java/sun-jdk" package installed (run "equo install dev-java/sun-jdk" as root in a console - this will reinstall if already installed) (currently, in Sabayon 5, it's version 1.6.0.16)
2) as root:
Code: Select all
ln -s /opt/sun-jdk-1.6.0.16 /opt/sunjdk

The idea is to create a symbolic link that always points to your "latest" jdk from Sun. When you install a new JDK, say 1.6.0.17, you will need to delete this file and create the link to the folder containing the new jdk (again, must be done as root).
3) if you want to "enable" java for your user ("andreas" as far as I can tell from your screenshot), all you need is to edit the file "/home/andreas/.bashrc" and look for a line which sets the PATH enviroment variable; it may look like this:
Code: Select all
export PATH=/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/games/bin

or it may be missing entirely. It could also set the variable in one line and export it later, like:
Code: Select all
PATH=...
...
export PATH


In this PATH variable, you just need to place "/opt/sunjdk/bin" in front of everything else (you might have noticed that : is the separator); in the above example, it would look like this:
Code: Select all
export PATH=/opt/sunjdk/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/games/bin:.

(I just added the current directory as part of the PATH in the end 'cause I always hate it when I have to run scripts as "./some_script.sh")

Now, all you need to do is restart your konsole and it will recognize both java and javac without any more problems. I don't know yet if this will cause any problems with Eclipse or some other IDE you might install from Entropy or Portage, but it will definitely fix your command line issue.

PS: remember, if an update occurs, you will need to change the symlink to point to the new JDK (as far as I can remember, installing a newer JDK in Sabayon causes the older one to be deleted, so the link will point to an invalid location and Java wouldn't work anymore).
Catalin Pol
Location: Romania
Linux user since 2004; Sabayon user since 2006
thecata
Simple Hen
 
Posts: 77
Joined: Sun Nov 12, 2006 11:40
Location: Romania, Cluj

Re: Run Java-Problem!!!

Postby Stupot » Thu Nov 05, 2009 18:44

An easier way to add a directory to the PATH variable is:
Code: Select all
PATH=/new/path:$PATH
export PATH

instead of copying and pasting what the PATH variable is already set to, just use the variable itself.
Stupot
Sagely Hen
 
Posts: 1545
Joined: Wed Feb 14, 2007 3:44
Location: St. Louis, MO, USA

Re: Run Java-Problem!!!

Postby micia » Thu Nov 05, 2009 20:32

micia
Sagely Hen
 
Posts: 2718
Joined: Wed Nov 26, 2008 16:41

Re: Run Java-Problem!

Postby andreas_g » Sat Nov 07, 2009 4:36

Micia thank you for one more time!!!! It works!!!! :D

Thecata thank you for your big post, but I choose micia's way because it was so much easier!!!

And one last thing.........it is necessary to do this every time I update java???
Sorry for my bad english!!!!!!!
andreas_g
Young Hen
 
Posts: 31
Joined: Sun Sep 14, 2008 0:43
Location: /home/andreas/greece

Re: Run Java-Problem! [Solved]

Postby micia » Fri Nov 13, 2009 11:24

Sorry for being really late on this, I have been very busy these days (and it is not over
yet :cry: ).
I do not think that it is necessary to do it every time, in Gentoo based systems the JDK actually
includes the JRE, so you could remove the JRE keeping just the JDK package.
Doing so, you will have only JDK targets as System VMs and you should not need to do this any more.

I have both packages and once I did this, I never had to do it again, but I am not sure about this...
micia
Sagely Hen
 
Posts: 2718
Joined: Wed Nov 26, 2008 16:41


Return to Software in General

Who is online

Users browsing this forum: No registered users and 2 guests