Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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?
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).
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!!
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.