[java] little Java help?

Started by
5 comments, last by OrbotDotH 21 years, 10 months ago
I am new to Java and have a few basic questions. I just downloaded the Java 2 1.4 JRE & SDK. I''m using an IDE called JCreator and have it set up fine, but shouldn''t I be able to type "javac whatever.java" and then "java whatever.class" at the DOS prompt to compile and run too? This doesn''t work. How do I set this up? (I''m using Win98) Also, is it possible to use OpenGL with Java? And finally, are making singleton classes preferred in Java? (I have a C++ background.) Is this commonly done or is there some other Java-ish method to accomplish the same thing? Thanks!!!!
Advertisement
Whenever you type "javac whatever.java" windows has no idea where to find javac or any of the other JDK tools. Whilst in your dos prompt I believe you can set the necessary path to the JDK tools using the following command... (I think its right)

SET PATH=C:\Java\JDK1.4\bin (or wherever your JDK bin is)

The command simply informs windows that there are useful tools in there that you will want to use every so often.

If that works then you can add it to your autoexec and you wont have to do it every time you open a dos prompt.

As for GL in Java. I believe there is a GL4Java kit out there. I have no idea how to use it or how good it is but a quick search on this very forum should reap rewards.

Anyway, hope that helped and didn''t sound to condescending.

P.S. I aint got a clue about singletons so someone else will have to tell you about them.
Seconds later and I''ve found that GL 4 Java stuff...

http://jausoft.com/gl4java/

hope that helps.
You also need to make sure that whatever.java and whatever.class are in your classpath. And when you want to run it, use java whatever without the .class appended.

As far as singletons go, it''s an OO design pattern. Use it wherever it applies. It doesn''t get more OO than Java.
Thanks for the quick answers! Everything is working perfectly now!
I use singletons all the time in Java. I typically design with Manager type design patterns, and usually I want one manager to exist for the application, especially in a multithreaded situation where two different threads may need to access the "FileManager", or the "SoundManager", or the "InputManager", for instance. Singletons really help there. They are very easy to create in Java. Just have a private static member variable to store your class instance, a private constructor, and then a getManager() method that creates and returns the static.
instead of openGL for java, try using java3d.
java3d uses opengl for rendering, but provides a scene graph API.
its much simpler to use for begineers, but lacking in functionality...

java3d supposedly can use direct3d also, but much worse support and performance...



Its my duty, to please that booty ! - John Shaft

This topic is closed to new replies.

Advertisement