I tried to run java 3d in Linux, here is the steps:
1. download the following 4 files which are necessary for the
installation:
java3d-re-1.3-beta2-linux-i386.bin
java3d-sdk-1.3-beta2-linux-i386.bin
LICENSE-Java3D-1.3-beta2.txt
README-Java3D-1.3-beta2.txt
2.become root:
% su root
Password: enter root password
#
3. bash java3d-re-1.3-beta2-linux-i386.bin
yes
bash java3d-sdk-1.3-beta2-linux-i386.bin
4. exit the root.
5. demo/java3d/HelloUniverse$ java HelloUniverse
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/media/j3d/Node
WHen I tried to run HelloUniverse, there is error:
NoClassDefFoundError: javax/media/j3d/Node.
I am sure that this is the problem of path setting. But how?
Thanks a lot for your hints.
btw. I guess that I should post this question into
comp.lang.java.java3d. But there are much less visitor there and I
always can not get answer. So I have to post this question here. Sorr.y
tony
You should be in the jre root (e.g. $JAVA_HOME/jre) when you do your
step 3, so the jarfiles end up in $JAVA_HOME/jre/lib/ext.
/gordon
--
[ do not email me copies of your followups ]
g o r d o n + n e w s @ b a l d e r 1 3 . s e
$JAVA_HOME should refer to the top level directory of your JDK
installation. Where did you install the JDK?
"echo $JAVA_HOME" will tell you the value of JAVA_HOME, if there is
such a variable (there might not be one).
Or try typing "type -a javac" to find out where to start looking for
the JDK. Javac *should* be in the bin directory of your JDK, but it
*could* be somewhere else, for example if it's a symbolic link.
rakta:~/java/j2sdk1.4.2_08/demo/java3d/HelloUniverse$ javac
HelloUniverse.java
rakta:~/java/j2sdk1.4.2_08/demo/java3d/HelloUniverse$ java
HelloUniverse
Exception in thread "main" java.lang.NoClassDefFoundError:
javax/media/j3d/Node
This means, javac can work, but java can not. Shall I set some
classpath?
Thanks in advance!
tony.
Sorry I didn't notice that you downloaded both java3d-sdk and
java3d-re. These packages unpack into slightly different paths, and
consequently you need to be in a different place when you unpack them.
The jar files should end up in $JAVA_HOME/jre/lib/ext, as I mentioned
earlier, and the library (.so) files in $JAVA_HOME/jre/lib/i386. If
the files are there, then both javac and java should work.
To unpack java3d-sdk, you should be in JAVA_HOME (the root dir of your
JDK).
To unpack java3d-re, you should be in JAVA_HOME/jre. Note that if you
already unpacked the sdk, you don't need the jre.
Still the same error. This means that java can not find the package
javax.
3. Then I set:
export CLASSPATH=./:$HOME/.lib:$JAVA_LOCAL/lib:$JAVA_HOME/jre/lib/ext
$JAVA_HOME/jre/lib/ext is where jar files stays. But it still can not
work.
Why?
> rakta:~/java/j2sdk1.4.2_08/demo/java3d/HelloUniverse$ java
> HelloUniverse
> Exception in thread "main" java.lang.NoClassDefFoundError:
> javax/media/j3d/Node
I wonder if "java" is finding the wrong java installation. As far as I know,
setting the CLASSPATH isn't necessary for properly installed java "extensions"
(javax.* packages). You could try typing:
type java
if that doesn't reply something like:
java is <somewhere>/bin/java
where the <somewhere> is a java installations that you've added the 3d
extensions to, then that would (I think) explain what's going wrong. That
could happen if you have a JRE installed (without the 3d stuff) earlier on your
classpath than the JDK (with the 3d stuff) -- in that case "javac" would find
the right compiler, but "java" would find the wrong java runtime.
-- chris
rakta:~$ type java
java is /usr/bin/java
so /usr is a java installation. You mean that JRE (without the 3d
stuff) and JDK (with the 3d stuff) were installed in the different path?
> Chris, you are right. Actually in this computer JRE (without the 3D
> stuff) was installed earlier by someone whom I do not know, then I
> istall the java3D. I guess that in this case "java" found the wrong
> java runtime. So should I reintall the whole JDK, JRE and java3D?
Bit late now, but FWIW, I would either add the 3s stuff to the "earlier" JRE
(if it's a late enough release of Java that you are happy to use it) or change
my $PATH and so on to exclude it from my environment.
I don't have any real experience of Java on Unix-like systems, but I've never
yet seen Unix system where the software installation wasn't a complete mess. I
generally find it easier (at least in the short term) to side-step the mess
than fix it.
-- chris
Personally, I'd just leave them in place and ensure that my $PATH (as well as
any Java-specific environment variables) did not point to the installations I
didn't want to use.
If you don't know what the $PATH is, or how to set enviroment variables, then
that's rather too big a topic for a newsgroup posting (especially in a Java
ng), and I suggest you get a good introductory book on Unix and/or Linux.
-- chris