LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-20-2005, 11:37 PM   #16
milo36472
LQ Newbie
 
Registered: Jan 2005
Posts: 13

Rep: Reputation: 0

thanks student04... 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 JRE path
PATH=$PATH:/home/robert/progfiles/j2sdk1.4.1_01/jre/bin:
JAVA_HOME=/home/robert/progfiles/j2sdk1.4.1_01/jre/bin

export PATH
export JAVA_HOME

export PATH=/home/robert/progfiles/j2sdk1.4.1_01/bin/:$PATH
# ------------------ end of JRE 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.

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
 
Old 01-21-2005, 12:37 AM   #17
mabus92920
Member
 
Registered: Jan 2005
Posts: 48

Rep: Reputation: 15
hhhmm.I'm not really sure..but I don't think "/bin" directory is needed when putting up the JAVA_HOME. .. just a wild gess
 
Old 01-21-2005, 02:40 AM   #18
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
mabus92920, the bin directory is correct, but there are a few errors...
Quote:
Originally posted by milo36472
# ------------------ start of my JRE path
PATH=$PATH:/home/robert/progfiles/j2sdk1.4.1_01/jre/bin:
JAVA_HOME=/home/robert/progfiles/j2sdk1.4.1_01/jre/bin

export PATH
export JAVA_HOME

export PATH=/home/robert/progfiles/j2sdk1.4.1_01/bin/:$PATH
# ------------------ end of JRE path
Let me explain. JAVA_HOME is just a variable that stores the path to your root java directory. It is used in PATH like this ${JAVA_HOME} to access it's contents, so that you do not have to type it in again. If you type the full path for PATH as you have, then you do not need add the variable JAVA_HOME anywhere, plus you exported the same folder twice. You have a slight mistake in the PATH line (I believe), and the jre/ folder is not correct. But that's ok not to worry.. the fix is below.

Here would be what you want in your path (you do not want the JRE path, just the main java path):
Code:
PATH=${PATH}:/home/robert/progfiles/j2sdk1.4.1_01/bin
export PATH
Those curly brackets keep the name of the variable in it; not having them indicates that everything followin the $ is the name of the variable.

If you would like to store your java path as a variable you would save it in JAVA_HOME and set it up the following way (I believe i typed my /etc/bashrc export lines in a previous post already.. all you had to do was paste in the correct paths):
Code:
JAVA_HOME=/home/robert/progfiles/j2sdk1.4.1_01
PATH=${JAVA_HOME}/bin:$PATH
export PATH
BOTH are the exact same thing. This should either go in /etc/bashrc for global settings for everyone, or into ~/.bashrc for only the user.

Once you edit either file, type "source ~/.bashrc" or "source /etc/bashrc" to load that configuration file into your current terminal; recompile and rerun the program.

I hope this fixes it

Last edited by student04; 01-21-2005 at 02:49 AM.
 
Old 01-22-2005, 08:26 AM   #19
milo36472
LQ Newbie
 
Registered: Jan 2005
Posts: 13

Rep: Reputation: 0
student04>>

all your assumptions regarding my bashrc settings were correct, and i
feel more comfortable doing things now... though i still have the same error

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


in running the following simple code (even though successfully compiled)

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 main
}//end of class



im thinking... maybe the problem is my jre because the following app executes perfectly

class HiWorld{
public static void main(String args[]) {
System.out.println("Hi World!");
}//end of main
}//end of class


and libfontmanager.so exists in the j2sdk1.4.1_01/jre/lib/i386 directory while
libstdc++-libc6.1-1.so.2 doesn't. maybe thats my real problem (is it?)
and maybe i need that file to run a java app using Frames as in the Jc_app class.
what do i do now???

im very grateful to all you people for your kind help, i really appreciate it!
 
Old 01-22-2005, 02:23 PM   #20
student04
Member
 
Registered: Jan 2004
Location: Georgia
Distribution: OS X, CentOS
Posts: 669

Rep: Reputation: 34
That is strange. I installed j2sdk1.4.1_07 which is almost your version, compiled your program successfully. I ran it with both java binaries located
j2sdk1.4.1_07/bin/java and
j2sdk1.4.1_07/jre/bin/java
The program ran fine. Now what i can only think of as the problem, is that the command "java" isn't linked to the correct one. We can test this by typing the full path to javac and java to test it. Try this out
Code:
$ /home/robert/progfiles/j2sdk1.4.1_01/bin/javac Jc_app.java
$ /home/robert/progfiles/j2sdk1.4.1_01/bin/java Jc_app
$ /home/robert/progfiles/j2sdk1.4.1_01/jre/bin/java Jc_app
 
Old 01-22-2005, 03:04 PM   #21
Kroenecker
Member
 
Registered: May 2003
Location: The States
Distribution: Gentoo
Posts: 245

Rep: Reputation: 30
I've just begun to try out Eclipse for C++ myself. I like. Possibly more than Anjuta becaue the interface is nicer. Time will tell.
 
Old 01-26-2005, 07:35 AM   #22
milo36472
LQ Newbie
 
Registered: Jan 2005
Posts: 13

Rep: Reputation: 0
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 guys!!!
 
  


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
Programing in Linux sdat1333 Linux - Newbie 4 12-15-2004 12:23 AM
Programing in Linux jimbob1989 Programming 1 10-10-2004 11:53 AM
Java Programing Tutorial embalmedlenin Programming 2 08-23-2003 10:53 AM
Java programing VincentB Linux - Software 3 07-14-2003 08:17 PM
About Java Sound programing figadiablo Programming 4 03-20-2003 11:01 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:47 AM.

Main Menu
Advertisement
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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration