Re: Help with packages getting started
- From: Lew <lew@xxxxxxxxxxxxx>
- Date: Fri, 28 Dec 2007 18:53:05 -0500
Lew wrote:
code. The tutorials on java.sun.com go into this.Ok, your going to have to explain things.
BlitzA wrote:
Possibly a step-by-step guide of how to get this working If you have time ? -
I assumed you were asking about my advice:
Use the -classpath (or -cp) option to your compilation and execution of Java code.
The tutorials on java.sun.com go into this.
But from your question
So theres a tutorial that specifically shows you how to make elements work with JDK 6.0 in a small step-by-step guide?
I see that I was mistaken. My advice was to fix the classpath - how to do that step by step is covered by Sun's tutorials.
If so please can you give the link?
http://java.sun.com look around for the links to the tutorials.
As I said, I'm talking about tutorials with respect to setting the classpath for Java, which is where your problem lies.
In a nutshell, you have to tell Java where the class is that you're trying to run, and as I pointed out earlier, that should most definitely not be in the Java installation directory tree, most especially particularly not in its bin/ subdirectory.
Knute Johnson wrote:
I don't know where the tutorial is either but you can look here for some more information on CLASSPATH;
www.knutejohnson.com/classpath.html
CLASSPATH is one of the trickiest pieces of programming with Java.
There are some important tips to remember;
1) You don't want to set the CLASSPATH environment variable except in
a few rare circumstances
Important point, to be sure.
2) The CLASSPATH has to include all the bits you want to compile or run
Lower-case classpath does, too. More precisely, it has to include all the parent directories and JARs of the bits you want.
3) If you use the -jar option on the command line to run a program
the -classpath or -cp command line options are ignored.
Also the CLASSPATH envar is ignored then.
2 is probably where your problem lies. I don't see a . in the CLASSPATH so how is the runtime going to find your class?
Lower-case. If there is no CLASSPATH envar and you don't specify a -classpath option, Java assumes "." as the classpath.
Sun's tools docs contain the page
<http://java.sun.com/javase/6/docs/technotes/tools/windows/classpath.html>
that gives excruciating detail.
So for the OP, this means picking a project directory, say, C:/projects, and building your stuff in a subdirectory there.
For project "example" with the source in a tree rooted at subdirectory src/, and classes going into a tree rooted at build/classes/:
cd /projects/example/src
javac -d ../build/classes com/lewscanon/example/App.java
cd ../build/classes
java com.lewscanon.example.App
If you don't cd to the build/classes subdir, you can use -classpath to run the program:
cd /anywhere/you/like
java -classpath /projects/example/build/classes com.lewscanon.example.App
If I needed a JAR to pull in a library, like /projects/libs/foo.jar, then it'd look like this:
java -classpath /projects/example/build/classes:/projects/libs/foo.jar \
com.lewscanon.example.App
The colon (:) would be a semicolon (;) in Windows environments.
Once all that is straight that original error should melt away.
--
Lew
.
- References:
- Help with packages getting started
- From: BlitzA
- Re: Help with packages getting started
- From: Lew
- Re: Help with packages getting started
- From: BlitzA
- Re: Help with packages getting started
- From: BlitzA
- Re: Help with packages getting started
- From: Lew
- Re: Help with packages getting started
- From: BlitzA
- Re: Help with packages getting started
- From: Knute Johnson
- Help with packages getting started
- Prev by Date: Re: question about the toString Method
- Next by Date: Re: Help with packages getting started
- Previous by thread: Re: Help with packages getting started
- Next by thread: Re: Help with packages getting started
- Index(es):
Relevant Pages
|