more dumb noob pain ("2dplot.clj")

11 views
Skip to first unread message

rebcabin

unread,
Dec 11, 2009, 12:15:52 PM12/11/09
to Clojure
I've been having pretty good luck writing my own programs and running
lots of samples from the contribute-files section of this google
group, but hit a roadblock this morning:

trying to run "2dplot," I installed java3d and it passes the tests on
https://j3d-webstart.dev.java.net/test/

but when I try to run 2dplot.clj, I get a
user=> (load-file "2dplot.clj")
java.lang.ClassNotFoundException: javax.media.j3d.BranchGroup
(2dplot.clj:23)

which is on the import of java3d; here's line 23, unchanged:

(import '(javax.media.j3d BranchGroup LineArray GeometryArray Shape3D
Transform3D TransformGroup BoundingSphere Background)
'(javax.vecmath Point3f Vector3f Point3d Color3f)
'(com.sun.j3d.utils.universe SimpleUniverse)
'(com.sun.j3d.utils.applet MainFrame)
'(com.sun.j3d.utils.behaviors.keyboard KeyNavigatorBehavior)
'(com.sun.j3d.utils.geometry Text2D)
'(java.applet Applet)
'(java.awt BorderLayout Font))

Any hints for me? I'm sure it's because I really don't know at all how
to find out where java things are installed and how to refer to them
if they're installed in weird places yadda yadda.

Erik Price

unread,
Dec 11, 2009, 12:37:46 PM12/11/09
to clo...@googlegroups.com
On Fri, Dec 11, 2009 at 12:15 PM, rebcabin <bc.be...@gmail.com> wrote:

Any hints for me? I'm sure it's because I really don't know at all how
to find out where java things are installed and how to refer to them
if they're installed in weird places yadda yadda.

Are the Java 3D jar files in your CLASSPATH?


devender

unread,
Dec 11, 2009, 6:34:07 PM12/11/09
to Clojure
You need this jar file j3d-core-1.3.1.jar in your classpath

If you are using leiningen then add this to your project.clj [java3d/
j3d-core "1.3.1"]

if not then you can download that jar from here
http://repo2.maven.org/maven2/java3d/j3d-core/1.3.1/

-Devender
On Dec 11, 9:15 am, rebcabin <bc.beck...@gmail.com> wrote:
> I've been having pretty good luck writing my own programs and running
> lots of samples from the contribute-files section of this google
> group, but hit a roadblock this morning:
>
> trying to run "2dplot," I installed java3d and it passes the tests onhttps://j3d-webstart.dev.java.net/test/

rebcabin

unread,
Dec 11, 2009, 6:34:22 PM12/11/09
to Clojure
Well, the 3d test applications from https://j3d-webstart.dev.java.net/test/
work correctly and every other Java test I've tried works, but I am
not sure how to find out what's on the CLASSPATH. Is CLASSPATH an
environment variable? If so, I don't have any binding for it, but then
the immediate question would be "how can ANY Java stuff work at all?"
Or is CLASSPATH set up somewhere and somehow else?

On Dec 11, 9:37 am, Erik Price <erikpr...@gmail.com> wrote:

Michael Wood

unread,
Dec 12, 2009, 2:54:19 PM12/12/09
to clo...@googlegroups.com
2009/12/12 rebcabin <bc.be...@gmail.com>:
> Well, the 3d test applications from https://j3d-webstart.dev.java.net/test/

Java Webstart works differently to something run from the command
line. When you click on the link it downloads a .jnlp file that, I
believe, mentions all the dependencies.

> work correctly and every other Java test I've tried works, but I am
> not sure how to find out what's on the CLASSPATH. Is CLASSPATH an
> environment variable? If so, I don't have any binding for it, but then
> the immediate question would be "how can ANY Java stuff work at all?"
> Or is CLASSPATH set up somewhere and somehow else?

CLASSPATH can be an environment variable, although, I'm not sure what
exactly expects it to be one. Normally I use the -cp option to the
java command to set the classpath, like this:

$ java -cp /path/to/clojure.jar:/path/to/clojure-contrib.jar:/path/to/j3d-core.jar
clojure.main

or

C:\> java -cp c:\path\to\clojure.jar;c:\path\to\clojure-contrib.jar;c:\path\to\j3d-core.jar
clojure.main

Perhaps a Java person can give you a better answer.

The way forward appears to be leiningen, in which case devender's
answer might be the best one.

--
Michael Wood <esio...@gmail.com>

rebcabin

unread,
Dec 12, 2009, 9:32:49 PM12/12/09
to Clojure
I got a lot closer thanks to the great hints above; the current state
is this

C:\usr\local\bin>java -cp clojure-1.0.0.jar;clojure-contrib.jar;j3d-
core-1.3.1.j
ar;j3dcore-ogl.dll;vecmath.jar;j3dutils.jar;j3dcore-d3d.dll
clojure.lang.Repl
Clojure 1.0.0-
user=> (load-file "/Users/Reb/workspace/2dplot/src/2dplot.clj")
java.lang.UnsatisfiedLinkError: no J3D in java.library.path
(2dplot.clj:0)

down to one missing thing

btw, I scroungd around Eclipse looking for a place to set the
CLASSPATH but didn't spot it. Anyone happen to know offhand?

thanks again for helping me get started :)

On Dec 12, 11:54 am, Michael Wood <esiot...@gmail.com> wrote:
> 2009/12/12 rebcabin <bc.beck...@gmail.com>:
>
> CLASSPATH can be an environment variable, although, I'm not sure what
> exactly expects it to be one.  Normally I use the -cp option to the
> java command to set the classpath, like this:
>
> $ java -cp /path/to/clojure.jar:/path/to/clojure-contrib.jar:/path/to/j3d-core.jar
> clojure.main
>
> or
>
> C:\> java -cp c:\path\to\clojure.jar;c:\path\to\clojure-contrib.jar;c:\path\to\j3d-core.j­ar
> clojure.main
>
> Perhaps a Java person can give you a better answer.
>
> The way forward appears to be leiningen, in which case devender's
> answer might be the best one.
>
> --
> Michael Wood <esiot...@gmail.com>

ataggart

unread,
Dec 12, 2009, 11:35:07 PM12/12/09
to Clojure
If it's a java project, then you can just select the jars, right-
click, choose Build Path > Add to Build Path. You can also do it
through Project > Properties >Java Build Path.

Michael Wood

unread,
Dec 13, 2009, 7:29:26 AM12/13/09
to clo...@googlegroups.com
2009/12/13 rebcabin <bc.be...@gmail.com>:
> I got a lot closer thanks to the great hints above; the current state
> is this
>
> C:\usr\local\bin>java -cp clojure-1.0.0.jar;clojure-contrib.jar;j3d-
> core-1.3.1.j
> ar;j3dcore-ogl.dll;vecmath.jar;j3dutils.jar;j3dcore-d3d.dll
> clojure.lang.Repl

By the way, clojure.lang.Repl is deprecated, I believe. Just use
"clojure.main" instead.

> Clojure 1.0.0-
> user=> (load-file "/Users/Reb/workspace/2dplot/src/2dplot.clj")
> java.lang.UnsatisfiedLinkError: no J3D in java.library.path
> (2dplot.clj:0)
>
> down to one missing thing

That sort of thing happens when you use a Java library that uses
native code. So you will have a dll that's used by one of the .jar
files. You can't just add the dlls to your classpath. Actually I
think java probably realises they are not directories or jar files and
therefore ignores them in the classpath.

On Linux/UNIX you'd add them to the shared library search path
(LD_LIBRARY_PATH or /etc/ld.so.conf etc.). On Windows, I believe the
PATH environment variable doubles as the DLL search path, and that the
current directory is hard coded into the PATH. From your classpath
above it looks like the DLLs were in your current directory, though,
so I'm not sure what the story is. Unless there's another DLL that
was needed and wasn't in your current directory or PATH.

> btw, I scroungd around Eclipse looking for a place to set the
> CLASSPATH but didn't spot it. Anyone happen to know offhand?
>
> thanks again for helping me get started :)

--
Michael Wood <esio...@gmail.com>
Reply all
Reply to author
Forward
0 new messages