LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   error in running a java app in linux (https://www.linuxquestions.org/questions/linux-newbie-8/error-in-running-a-java-app-in-linux-279700/)

milo36472 01-19-2005 08:34 AM

error in running a java app in linux
 
Help Please!!! im new in java programming in Linux and i got this error after successfully compiling my sample java application code

Exception in thread "main" java.lang.UnsatisfiedLinkError: /usr/java/j2sdk1.4.1_01/jre/lib/i386/libfontmanager.so: libstdc++-/ibc6.1-1.so.2: cannot open shared object file: No such file or directory

how do i fix this

brainlesspinkey 01-19-2005 12:50 PM

Can you give more info as to the conditions of this error?
Do other java programs work?
Can you maybe post the code?

-p

milo36472 01-23-2005 03:44 PM

thanks brainlesspinkey... heres my simple code im trying to run

import java.awt.*;
import java.awt.event.*;

class Jc_app extends Frame {

public Jc_app() {
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
dispose();
System.exit(0);
}
});
}

public static void main(String args[]) {
System.out.println("Starting Jc_app...");
Jc_app mainFrame = new Jc_app();
mainFrame.setSize(400, 400);
mainFrame.setTitle("Jc_app");
mainFrame.setVisible(true);
}
}//end of class


im not really sure about my problem, the code compiled succesfully with no error
and its very simple. maybe its in my compiler. when i installed my j2sdk1.4.1, it
seem to just have extracted itself. my installer was a bin file, after i run it
and accepted the term of use (agreement) i got this files extracted,

[robert@localhost robert]$ cd /home/robert/progfiles/j2sdk1.4.1_01
[robert@localhost j2sdk1.4.1_01]$ ls
bin/ COPYRIGHT* demo/ include/ jre/ lib/ LICENSE* man/ README* README.html* src.zip*
[robert@localhost j2sdk1.4.1_01]$ ls -l
total 10420
drwxr-xr-x 2 robert robert 4096 Sep 30 2002 bin/
-rwxr--r-- 1 robert robert 4431 Sep 30 2002 COPYRIGHT*
drwxr-xr-x 6 robert robert 4096 Sep 30 2002 demo/
drwxr-xr-x 3 robert robert 4096 Sep 30 2002 include/
drwxr-xr-x 5 robert robert 4096 Sep 30 2002 jre/
drwxr-xr-x 2 robert robert 4096 Sep 30 2002 lib/
-rwxr--r-- 1 robert robert 16955 Sep 30 2002 LICENSE*
drwxr-xr-x 4 robert robert 4096 Sep 30 2002 man/
-rwxr--r-- 1 robert robert 8729 Sep 30 2002 README*
-rwxr--r-- 1 robert robert 15639 Sep 30 2002 README.html*
-rwxr--r-- 1 robert robert 10568782 Sep 30 2002 src.zip*
[robert@localhost j2sdk1.4.1_01]$


its like the ones i have in my WindowsXP installation, then i changed my .bashrc
as instructed in the installation guide

# .bashrc

# User specific aliases and functions

# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi

# ------------------ start of my compiler path
PATH=${PATH}:/home/robert/progfiles/j2sdk1.4.1_01/bin
export PATH
# ------------------ end of compiler path


after doing that i assumed that everything is fine and in place
so i started programming... i tried running some applet demos in the
demo directory of my java installation and nothing wont run. i thought maybe
doing things as root will work, then i was able to run some of the applets but i
cant run any apps within the demo/jfc directory using java -jar <app.jar>

and im thinking that maybe the previous or existing installation of kaffe made
those applets to run. i really dont know.

i've received some suggestions from here

so here i am. i created a couple of snapshots and the program im trying to run in the
following URL, by the way im using Mandrake 9.2. Thank You!!!

http://m.1asphost.com/amacss/linux/java_err.htm

brainlesspinkey 01-24-2005 11:32 AM

I think at least one of the problems you might be having is with the bashrc file. instead of putting those two lines for the path, put this instead:

# ------------------ start of my compiler path
export PATH = $PATH:/home/robert/progfiles/j2sdk1.4.1_01/bin
# ------------------ end of compiler path

hope that works :)

also for future reference, it is usually better to put java (and other programs) in /usr or /opt so all people on your system can access it. for me persionally, I have java installed in /usr/java/j2sdk1.4.1_01 . From your previous error, it seems that for some reason java might need to be installed there.
However, for other manually installed programs, i like to put them in /usr/local

If all that doesn't work, try and get a more up-to-date version of java maybe.

brainlesspinkey 01-24-2005 11:35 AM

i just remembered- also maybe try makeing a JAVA_HOME env variable.

# ------------------ start of my compiler path
export JAVA_HOME = /home/robert/progfiles/j2sdk1.4.1_01
export PATH = $PATH:$JAVA_HOME/bin
# ------------------ end of compiler path

so heres the steps:
First just try to change your path
If that doesn't work, try the javahome variable
If that doesn't work, try putting java in /usr/java/j2sdk1.4.1_01 (don't forget to change your env variables)
If that doesn't work, post all the errors you get, and we'll go from there.

-pink

brainlesspinkey 01-24-2005 11:50 AM

It seems also, from those screenshots you showed, that you have two java's in your path: one in /usr/bin/java and another in your /home folder. to see if this is the problem, try to compile your program by typing
/home/robert/progfiles/j2sdk1.4.1_01/bin/javac (program).java
and then /home/robert/progfiles/j2sdk1.4.1_01/bin/java (program)

if this ^^ works, and solves your problem, then so you don't have to constantly type that long command:

as root, go into /usr/bin/java, make a new folder and call it javabkup, and move all the java related commands in /usr/bin/ into /usr/bin/javabkup. then try to run java. if things get really screwed up, move the files in javabkup back into /usr/bin

From my experience with mandrake, they put /usr/bin/java and /usr/bin/javac in order to be just place savers for the real java. you just need to move the place savers so it will run the version of java you want.

Hope i haven't bombarded you with too much info, and good luck!

milo36472 01-26-2005 06:32 AM

i tried to trace my problem by looking at the files in /usr/bin directory
i observed that java (an Executable File) is actually a link (i guess) to /home/robert/progfiles/j2sdk1.4.1_01/bin/java
and javac (an Executable File) is also a link (another guess) to /home/robert/progfiles/j2sdk1.4.1_01/bin/javac
while appletviewer (a Shell Script) is linked to /etc/alternatives/appletviewer
and then i looked for the alternatives directory in etc, i found out that appletviewer is
linked to /usr/lib/kaffe/bin/appletviewer, this might be the reason that i was able to
execute an applet and while everytime i run a java app or an applet using my (assumed to be)
java installation i always get that error (stated in my earlier posts).
though i can compile java codes using the compiler in my (assumed to be) java installation
which is in /home/robert/progfiles/j2sdk1.4.1_01

and so with my new findings (i havent tried it before) i compiled run both my app and applet sample codes...

[robert@localhost applet]$ /usr/lib/kaffe/bin/javac Jc_app.java
[robert@localhost applet]$ /usr/lib/kaffe/bin/java Jc_app

[robert@localhost applet]$ /usr/lib/kaffe/bin/javac Jc_applet.java
[robert@localhost applet]$ /usr/lib/kaffe/bin/appletviewer index.htm

and i was surprised that it both run... my sample application displayed a window
as it is supposed to do.

but when i tried to run a demo app in my j2sdk installation using
java -jar Notepad.jar //the simple Notepad.jar demo i got this error

java.lang.NoClassDefFoundError: javax/swing/JPanel
at java.lang.ClassLoader.defineClass0 (ClassLoader.java)
at java.lang.ClassLoader.defineClass (ClassLoader.java:179)
at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:33)
at kaffe.lang.AppClassLoader$JarSource.findClass (AppClassLoader.java:143)
at kaffe.lang.AppClassLoader.findClass (AppClassLoader.java:291)
at java.lang.ClassLoader.loadClass (ClassLoader.java:142)
at java.lang.ClassLoader.loadClass (ClassLoader.java:121)
at kaffe.jar.ExecJarName.main (ExecJarName.java:55)
at kaffe.jar.ExecJar.main (ExecJar.java:75)


and so now im thinking that my kaffe installation (preinstalled in Mandrake)
was too old (i guess) to understand that Notepad demo...

[robert@localhost applet]$ /usr/lib/kaffe/bin/java -version
Kaffe Virtual Machine

Copyright (c) 1996-2002 Kaffe.org project contributors (please see
the source code for a full list of contributors). All rights reserved.
Portions Copyright (c) 1996-2002 Transvirtual Technologies, Inc.

The Kaffe virtual machine is free software, licensed under the terms of
the GNU General Public License. Kaffe.org is a an independent, free software
community project, not directly affiliated with Transvirtual Technologies,
Inc. Kaffe is a Trademark of Transvirtual Technologies, Inc. Kaffe comes
with ABSOLUTELY NO WARRANTY.

Engine: Just-in-time v3 Version: 1.1.1 Java Version: 1.1
[robert@localhost applet]$

just FYI, i got my J2SDK from a book w/ a CD, which also includes J2sdk
and Sun One Studio4 Community ed. for both windows and linux. (sigh)

i guess my problem after all was my J2SDK installation...
i tried to follow the very brief installation instruction which says

* Installing Java 2SDK:
* Choose either the Windows or Linux folder located in the root of this CD-ROM.
* Browse to the jdk14 directory and double click on j2sdk-1_4_1_01-linux-i586.bin for Linux or
j2sdk-1_4_0_02-windows-i586.exe for Windows to begin the setup process.

i did do it but double clicking wont work... i assumed that it was a self extracting binary so i did
chmod a+x j2sdk-1_4_1_01-linux-i586.bin and agreed to the license agreement, it extracted to
my given directory... (and here i am)

thats my java adventure(and dilemma) so far... it would really be great if i can make it to work
with your help, even if i reinstall java. (downloading a new SDK is not yet an option)
tons of thanks to you!!!

brainlesspinkey 01-26-2005 02:49 PM

whooo now things are getting interesting.

Ok - That error you get when you run notepad.jar with kaffe is because it has been compiled with a higher version, like you suspected. If I were u, I'd just uninstall kaffe totally. in mandrake, i think you can use something in the control center to do this. I'd uninstall everything java, and remove all the symblinks to java from /usr/bin (keep backups by just moving them to a folder) and remove java from your path. To comfirm that everything is gone, run the command java, and javac and appletviewer to make sure they can't find it.
THEN
As root:
Move the j2sdk.run file into /usr/java
Then run it to install j2sdk into /usr/java
Then put /usr/java/j2sdk/bin in your .bashrc path.
So then everything should be normal - try running java -version to see if it is the correct version.

If you install other versions of java in the future, you can put them also in /usr/java, and then just change your path to what ever version of java you want to currently run.

milo36472 01-29-2005 11:19 AM

i did it... still it wont work... maybe i should just get an rpm installation
unless theres still some HOPE of getting it to run...

thanks for all your help pink!!!!

brainlesspinkey 01-29-2005 03:02 PM

did you totally uninstall everything? To check, try to run java and make sure it can't find the command.

milo36472 01-30-2005 11:19 AM

i cant say that i really uninstalled my previous java installation because in the first place it just extracted itself

my so called j2sdk installer was j2sdk-1_4_1_01-linux-i586.bin to install it i typed
./j2sdk-1_4_1_01-linux-i586.bin
then the license agrrement came out. i accepted it then as i've said it just
inflated itself, which ended up as my installation... so what i just did to say uninstall it
was i deleted those files, edited my bashrc and tried to compile and run java whish it wont
work anymore, it cant find it anymore and because i also relocated the references(symbolic link) to kaffe.

/*im sorry if im giving you a hard time, i hope not */

brainlesspinkey 01-30-2005 01:53 PM

ok, the .bin file is just basically a self extracting zip file. So, what you did to uninstall it was correct. But I think you should also try to uninstall kaffe and all the symblinks that went with that. Make sure nothing java can run. Then, inflate the bin file, put it in /usr/java, edit your .bashrc file, and then try it.

/* don't worry about it, this is fun */

milo36472 02-02-2005 07:26 AM

i did again what you wanted me to do... but still it wont work... i think its really my .bin file...

/*thanks =) */

brainlesspinkey 02-08-2005 10:50 PM

ok, if you think it is the bin file, try this to confirm it:
Try the commands with the full path:
/home/robert/progfiles/j2sdk1.4.1_01/bin/javac (program.java)
/home/robert/progfiles/j2sdk1.4.1_01/bin/java (program)
If that gets you the same error, the problem is with the bin file. Remember to leave off the .java extension when you execute the program.
Hope that helps :)

-p

milo36472 02-09-2005 01:34 PM

i did the last thing you said and im still unfortunate to have the same error...
i guess i need to get a new SDK. the SDK from the CD might really have a problem.

pink, what would you suggest, the rpm one or the bin one?
to your knowledge, is there a difference between the two?

thanks a lot pink, your a great deal of help for a newbie like me :D


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