LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   Rpm Trouble Red Hat 7.3 (https://www.linuxquestions.org/questions/linux-software-2/rpm-trouble-red-hat-7-3-a-30908/)

OrganicX 09-21-2002 04:09 PM

Rpm Trouble Red Hat 7.3
 
I'm trying to install java on red hat 7.3

when I run j2sdk-1_3_1_03-linux-i386-rpm.bin, im asked to read an agreemnet, after I accept, the pakage gets extracted no problem. when I type rpm -iv jdk-1.3.1_03.i386.rpm, i get three error messages

error: cannot get exclusive lock on /var/lib/rpm/Packages
error: cannot open Packages index using db3 - Operation not permitted (1)
error: cannot open Packages database in /var/lib/rpm

although when I type rpm -iv jdk-1.3.1_03.i386.rpm in root, I get the message 'package jdk-1.3.1_03-fcs is already installed'.

when I type ls -la in the directory as root, I dont see any package like that installed, and when I try to compile a java application in that directory as root, I get the message 'javac: command not found'.

I'm new to Linux and Java and was following the tutorial from suns website on how to install java on linux. I also searched google for similar error messages but didnt understand any purposed solutions, besides everyone seemed to have a different answer. Im not sure what to do, like I said I'm new to the whole thing. If you have encountered this type of error and have solved it, I would love to know how.
thanks

P.S. I also have j2re-1_3_1_03-linux-i386-rpm.bin, do I need to open that and then run rpm on that first? I dont even know what j2re-1_3_1_03-linux-i386-rpm.bin is.

DavidPhillips 09-21-2002 11:25 PM

try uninstall first

rpm -e packagename

if it says it's not installed then you should be able to install it

if you still can't do it use --force to install it

neo77777 09-22-2002 12:39 AM

JRE is Java Runtime Environment, if you don't want to program in Java it is the lesser way to make your system java aware - browser plugins, etc. If you want to create Java programs SDK (Software Development Kit) is the way to go.

OrganicX 09-22-2002 11:27 AM

Thanks guys

Faecal 09-22-2002 05:06 PM

To elaborate for your clearer understanding:

although when I type rpm -iv jdk-1.3.1_03.i386.rpm in root
Well done, not being root was the only thing causing those first few error messages.

when I type ls -la in the directory as root, I dont see any package like that installed
Well, ls only lists files in the directory. To see whether a package is installed, you use "rpm -q <package-name>". If you're not quite sure of a package's exact name (you'd have to have had correct case, etc), you can use "rpm -qa | grep -i <idea of part of name>". That pipes the output of rpm -qa which lists all installed packages (query all) into grep (searches for strings). grep will output any line from rpm -qa's output that contains the string you specify.

OrganicX 09-22-2002 10:12 PM

thanks for the advice faecal but when I search the package name

rpm -q jdk-1.3.1_3.i386.rpm in the directory as root, I get the message

package jdk-1.3.1_3.i386.rpm is not installed

so I typed the following

rpm -iv jdk-1.3.1_3.i386.rpm

and get the message

package jdk-1.3.1_3-fcs is already installed

so I tried

rpm -iv --force jdk-1.3.1_3.i386.rpm

and received the following

Preparing packages for installation...
(a few seconds go by)
jdk-1.3.1_3-fcs

so I tried to compile a program, not knowing if installing the package worked

javac Program.java

and get

javac: command not found

(I did all this as root)

Am I missing something?

Faecal 09-23-2002 02:34 AM

It certainly does sound strange that the package is installed but javac isn't happening.

When you're referring to packages with the rpm command, the package name is just the first part, in this case simply "jdk", not the full filename. Another example would be xmms-devel-1.2.7-1.i386.rpm - the package name is just "xmms-devel".

I wouldn't recommend using force - if you want to install a newer version of a package over an older version, you can use rpm -U (upgrade) or if you want to install a package which is the same version as that which is already installed, you can use rpm -F (freshen).

Try "rpm -q jdk". If that spits back a version number, try "rpm -ql jdk" - that (query, list) will output a list of files that were installed by the package. See if javac is there. If it is, note its location, and try running it using the entire explicit path to javac. If that works, then the only remaining problem is that javac isn't on your path. "echo $PATH" will show you your path. Ask again if you need to know how to add something to your path.

OrganicX 09-23-2002 08:27 AM

thanks for all you help faecal, I tried

rpm -ql jdk

and It spit back a lot of paths so I did

rpm -ql jdk | more

and looked for javac

I found the following with the word javac.

/usr/java/jdk1.3.1_03/bin/i386/green_threads/javac
/usr/java/jdk1.3.1_03/bin/i386/native_threads/javac
/usr/java/jdk1.3.1_03/bin/i386/native_threads/oldjavac
/usr/java/jdk1.3.1_03/bin/javac
/usr/java/jdk1.3.1_03/bin/oldjavac
/usr/java/jdk1.3.1_03/jre/bin/i386/green_threads/javac
/usr/java/jdk1.3.1_03/jre/bin/i386/green_threads/oldjavac
/usr/java/jdk1.3.1_03/man/ja_JP.eucJP/man1/javac.1
/usr/java/jdk1.3.1_03/man/man1/javac.1

so Im assuming I do have a javac file

so them I typed pwd to confirme where I was and I was in

/tmp (the same directory where i tried to compile my code and this is the same directory where the jdk package is located)

Am I trying to compile my code in the wrong directory?
should I be writing and compileing my code in the /usr directory or some other directory in the /usr directory or am I completely off the mark?

this may be related or not but when Im in the /usr directory and type

ls

I see a java directory (as seen in the paths above). so I did an ls -l to make sure and, yes there is a java directory so I tried

cd /java (as both root and a regular user)

and got the same message as both users

cd: /java: No such file or directory

is this related to my problem or does all this have nothing to do with my problem?

:cry:

Faecal 09-23-2002 08:41 AM

cd /java and cd java have very different meanings! That slash at the start makes bash think that you're looking for the folder at the base of the directory tree. You might type "cd /usr" and then "cd java", or just "cd /usr/java".

Getting back to your problem...

/usr/java/jdk1.3.1_03/bin/javac - this is our baby! What you need to do is add the /usr/java/jdk1.3.1_03/bin/ directory to the list of paths that the shell searches when it's looking for an executable.

If I type "blarg" (or some other nonsense) at my prompt, bash will search through directories such as /usr/bin, /bin, ~/bin looking for a file of that name to execute. Doesn't find it in any of the directories it knows about, so it gives me an error.

bash's information about where to find executables is stored in an environment variable called PATH. To see what your path is at present, you can type "echo $PATH". To add a directory to your path, you can type "PATH=$PATH:<your directory>", so you'd type "PATH=$PATH:/usr/java/jdk1.3.1_03/bin/". After doing that, you'd find that you could just type "javac" at the prompt, and bash would find an execute it.

The caveat is that your PATH is reset every time you logoff. To make your setting persistant, you can add your "PATH=$PATH:/usr/java/jdk1.3.1_03/bin/" to the .bashrc file in your /home/<user name> directory.

Once the path is set up properly, you can work on your code whereever you like. Not in the /usr directory! To access that you need to be logged on as root, and one should always used one's system as a regular user, to decrease your security vulnerability. Only use root when you need to do something that only root can do. Just create yourself a ~/java directory or something (~ is the symbol that means your home directory).

OrganicX 09-23-2002 10:18 AM

IT WORKS!!

Faecal, you solved my problem. I followed your instructions and now I can write, compile and view the results of my programs. I even modified .bashrc as you said and rebooted and it still works. Im so happy, thank you, thank you, thank you!!

:D

DavidPhillips 09-23-2002 02:02 PM

also you may do this

I think it should be that way



ln -s /usr/java/jdk1.3.1_03/bin/javac /bin/javac



this creates a link in /bin

Faecal 09-24-2002 05:29 AM

DavidPhillips: mmm, using a symlink occurred to me, but I decided to play safe and recommend putting it in the path - I'm not familar with the java SDK, so I didn't know if other binaries might be needed. Fair point though, it does get a bit silly if you're putting every installed program's directory in PATH.

OrganicX: No problem :-)


All times are GMT -5. The time now is 04:18 AM.