LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-28-2002, 02:27 PM   #1
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Rep: Reputation: 0
java library problem


i've been doing my programming on mandrake 7.2, and so far it's been working fine for me without any problems. for my latest programming assignment i need to use some of the javax/swing libraries, but i guess my java compiler can't find them when i compile. when i try to compile a program using the javax/swing/JPanel library, i get this message:

"Cannot find type 'javax/swing/Jpanel'"

thinking that i may simply need to update things on my system, i downloaded the j2re 1.4 bin and the j2sdk 1.4 bin and they seemed to install successfully with rpm. at least, i got no messages. this didn't fix my problem. also, i installed the rpm files from a directory i created on my desktop. is it possible i didn't install from the right directory?

i have no idea where my linux distro is storing all the java stuff, and i'm pretty lost about what i should do next. is there a place where i can look at what java libraries are available, and if i see that what i need isn't there how do i get them there? any advice will help me, as i'm feeling pretty clueless.

also, i know these programs will compile and work properly as they work fine on the linux machines at school, so i know this isn't an issue of bad programming. just an ignorant linux user.
 
Old 04-28-2002, 03:12 PM   #2
dsledge
Member
 
Registered: Dec 2001
Location: Georgia
Distribution: Ubuntu
Posts: 31

Rep: Reputation: 15
Hi!
On my RedHat box, I needed to set the environent variable in the bash profile. I had to add a path to the java directory. For more info, see the "Java Environment Help" link at the bottom of this message.
Here is a copy of my file:
---------------------------
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin
PATH=/usr/java/j2sdk1.4.0/bin:$PATH <<<------this is the path for java
PATH=/usr/share/jgrasp/bin:$PATH
JGRASP_HOME=/usr/share/jgrasp:$PATH
export PATH
unset USERNAME
----------------------------------

Dennis


Java Environment Help
 
Old 04-28-2002, 03:31 PM   #3
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Original Poster
Rep: Reputation: 0
thanks for that link for the life of me the java page at sun is a real bitch to navigate and find what you want...
 
Old 04-28-2002, 10:34 PM   #4
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Original Poster
Rep: Reputation: 0
ok... i fixed my problem to the degree that i can get the program to work. the catch is that when i upgraded and installed java, it put everything into /usr/java, and if i want to compile the program i have to type this big awkward command instead of just javac:

/usr/java/j2sdk1.4.0/bin/javac "name of program".java

how do i edit my bash profile so that it goes straight to that directory when i simply use the javac or java commands? when i type:

which java

it gives:

/usr/bin/java

isn't there a command i can use to change the path? i still cannot find this place that you or the java site mentioned to edit the bash profile.
 
Old 04-28-2002, 11:10 PM   #5
gui10
Member
 
Registered: Mar 2001
Distribution: enigma, slack8
Posts: 677

Rep: Reputation: 30
okay... there are 2 ways to do it.

you can create a script file that goes like this:
/usr/java/j2sdk1.4.0/bin/javac
and save it as whatever file name you like.
and then change its permissions for it to become executable.
copy this file to wherever u want to compile your java files.
eg. if you named the file compilejava, just run the script by typing ./compilejava yourFileName.java

the other method is to edit your .bash_profile file. note that you need to have the dot right in front of the file name. add in the line where dsledge indicated was the path for java. save the file

you should be able to use the commands javac, java, javadoc etc etc from then on.

Last edited by gui10; 04-28-2002 at 11:13 PM.
 
Old 04-28-2002, 11:49 PM   #6
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Original Poster
Rep: Reputation: 0
Quote:
Originally posted by gui10
okay... there are 2 ways to do it.

the other method is to edit your .bash_profile file. note that you need to have the dot right in front of the file name. add in the line where dsledge indicated was the path for java. save the file

yeah, exactly. but i don't know how to get into .bash_profile to edit it. i don't know what directory i should be in, i don't know what command to use to get in there or whether i should use an editor, and i'm also suspicious that when i get there i won't find anything that looks like the java stuff i need to change. i tried various commands in various directories, to no avail. plus i thought i had to actually edit .bashrc. either way, i've tried finding both of those but nothing's working for me.
 
Old 04-29-2002, 08:05 AM   #7
zmedico
Member
 
Registered: Feb 2002
Location: Mission Viejo, California, USA
Distribution: Gentoo
Posts: 707

Rep: Reputation: 30
Quote:
Originally posted by sbrattt
when i type:

which java

it gives:

/usr/bin/java
That is where "kaffe" installs java! To see if kaffe is installed, do "rpm -q kaffe" To remove kaffe, do "rpm -e kaffe"
 
Old 04-29-2002, 06:01 PM   #8
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Original Poster
Rep: Reputation: 0
ok, but how do i edit my bash profile? i'm not going to unistall kaffe until i know it's know it's not going to screw anything up. maybe i'm just dreaming here, so correct me if i'm wrong, but is there not a bash profile somewhere out there where i can find the crap related to my java/javac commands and edit the path where it gets the program connected to those commands??!? is there not a file i can simply open in vi, find what i'm looking for, and change it?

i'm using mandrake 7.2, and i've run across this kaffe stuff you mentioned but i'd like to know a more about it before i mess with it.
 
Old 04-29-2002, 10:06 PM   #9
dsledge
Member
 
Registered: Dec 2001
Location: Georgia
Distribution: Ubuntu
Posts: 31

Rep: Reputation: 15
Hi again,
Your bash profile is located in your home directory. The name is: .bash_profile (notice the period). To get to the home directory from a command line, while logged-in as yourself and not root, simply type:
cd ~
ls -a
Configuration files are (almost) always hidden which is why you need the -a switch in the ls command.

To edit the file you can do one of the following:
From the command line:
pico ~/.bash_profile (notice the period following the slash)(you could use any text editor, I'm assuming you have pico installed)

Now add the line as told in my first reply. Be sure this is where java is installed.
OR
using your favorite GUI file manager, change the settings such that you can see hidden files, open the .bash_profile file and make the changes.

Maybe this will solve your problem.

Dennis
 
Old 04-30-2002, 01:17 PM   #10
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Original Poster
Rep: Reputation: 0
ok, dsledge, i did what you said and got into my .bash_profile to edit it. i tried playing around with those lines you gave me, putting them in various places, but nothing has worked so far. here is what my .bash_profile looks like:



#.bash_profile
#Get the aliases and functions

if [ -f ~/.bashrc]; then
. ~/.bashrc
fi

#User specific environment and startup programs

PATH=$PATH:$HOME/bin
BASH_ENV=$HOME/.bashrc
USERNAME=""
HISTIGNORE="[ ]*:&:bg:fg"

export USERNAME BASH_ENV PATH HISTIGNORE


WHAT exactly do i need to insert and where should it go? again the java stuff i want to use is in /usr/java/j2sdk1.4.0/bin. this might be a dumb question, but all i need to do to edit properly is save the changes in my editor when i'm done... there's no sort of compiling or anything that needs to take place after this step right?
 
Old 04-30-2002, 02:17 PM   #11
zmedico
Member
 
Registered: Feb 2002
Location: Mission Viejo, California, USA
Distribution: Gentoo
Posts: 707

Rep: Reputation: 30
Quote:
Originally posted by sbrattt
i'm not going to unistall kaffe until i know it's know it's not going to screw anything up.
Don't worry about it, rpm won't let you remove packages if there are dependencies found in the rpm database. You can always reinstall it later if you want.
Quote:
Originally posted by sbrattt
but all i need to do to edit properly is save the changes in my editor when i'm done... there's no sort of compiling or anything that needs to take place after this step right?
You can log out and log in again to make the changes take affect.

Last edited by zmedico; 04-30-2002 at 02:19 PM.
 
Old 04-30-2002, 09:38 PM   #12
dsledge
Member
 
Registered: Dec 2001
Location: Georgia
Distribution: Ubuntu
Posts: 31

Rep: Reputation: 15
Quote:
Originally posted by sbrattt
ok, dsledge, i did what you said and got into my .bash_profile to edit it. i tried playing around with those lines you gave me, putting them in various places, but nothing has worked so far. here is what my .bash_profile looks like:



#.bash_profile
#Get the aliases and functions

if [ -f ~/.bashrc]; then
. ~/.bashrc
fi

#User specific environment and startup programs

PATH=$PATH:$HOME/bin
PATH=/usr/java/j2sdk1.4.0/bin:$PATH <<<-----ADD THIS LINE
BASH_ENV=$HOME/.bashrc
USERNAME=""
HISTIGNORE="[ ]*:&:bg:fg"

export USERNAME BASH_ENV PATH HISTIGNORE


WHAT exactly do i need to insert and where should it go? again the java stuff i want to use is in /usr/java/j2sdk1.4.0/bin. this might be a dumb question, but all i need to do to edit properly is save the changes in my editor when i'm done... there's no sort of compiling or anything that needs to take place after this step right?


See my addition to your file above. Save the file. Open a bash window. Type in: java -version You should now see:"java version 1.4.0" plus a few other lines. You are all set to program!!

Dennis
 
Old 04-30-2002, 11:21 PM   #13
sbrattt
LQ Newbie
 
Registered: Jul 2001
Location: Boise, ID
Distribution: mandrake 7.2
Posts: 20

Original Poster
Rep: Reputation: 0
muchas gracias everyone...
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot load .so file from java library path whalesurf Linux - Software 1 07-24-2006 11:43 AM
Java Library Issue (RHEL) ptreves Linux - General 1 07-20-2005 03:56 AM
error loading dynamic library with Java trutnev Programming 4 06-01-2005 03:33 PM
how to initialize the non standard Library in Java husniteja Programming 1 09-17-2004 08:30 PM
Error when trying to install java runtime library downinthemine Linux - Newbie 5 07-31-2003 02:49 AM


All times are GMT -5. The time now is 07:57 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration