Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

ClassPath

Hi everyone,

I need to ask a very generalised question about classpath.

Now i have a java class file named JTim.class

Now on the command line i run JTim like that

C:\j2sdk1.4.2\bin\java -cp .;C:\WINDOWS\Desktop\JProc\ JTim

Now do you guys see the folder in which JTim is in which is called
JProc. You see in JProc there is another folder called JProcTim

Now in the folder called JProcTim is a java class file also named
JTim.class

Now my question taking into account that to run the class JTim in the
JProc i did this

C:\j2sdk1.4\bin\java -cp .;C:\WINDOWS\Desktop\JProc\ JTim

is why does the intrepreter run the JTim class in the JProcTim folder and not the one i specified which is the JTim class in the JProc folder?

Any help is greatly appreciated

Thank You

Yours Sincerely

Richard West
[957 byte] By [freesoft_2000] at [2007-11-11 6:42:53]
# 1 Re: ClassPath
It sounds like the CLASSPATH is searching to the JProcTIm folder before it gets to the JProc folder and is therefore compiling the version found there rather than in JProc.

At one point did you put JProcTim on your CLASSPATH?

Have you rebooted since you did that?

Did you make this entry permanent?

There IS an explanation ... guess you just need to puzzle it out ...
nspils at 2007-11-11 22:40:26 >
# 2 Re: ClassPath
Hi everyone,

At one point did you put JProcTim on your CLASSPATH?

Yes

Have you rebooted since you did that?

Yes

Did you make this entry permanent?

No

I find this very weird as i have never experienced anything like this before as you can see from the way i run the java programs i always redefine the classpath so why this is happening is really alien to me.

Have you ever experienced anything like this before?

I am setting the classpath abovr correctly am i not?

Yours Sincerely

Richard West
freesoft_2000 at 2007-11-11 22:41:32 >
# 3 Re: ClassPath
Sounds like user error.
How are you sure that the two programs with the same name are different and that the one in the JPProcTim folder is being executed?
Could the JProc.class files be the same in the two folders?
What happens if you rename the .class file you don't want executed to say .xxx and then execute the java command?
The line you posted
C:\j2sdk1.4.2\bin\java -cp .;C:\WINDOWS\Desktop\JProc\ JTim

doesn't have the program name on it? How does it work w/o that?
Norm at 2007-11-11 22:42:35 >
# 4 Re: ClassPath
As Norm suggested - try it with the "JTim" left off ... finish with the "JProc\"
nspils at 2007-11-11 22:43:28 >
# 5 Re: ClassPath
Hi everyone,

How are you sure that the two programs with the same name are different and that the one in the JProcTim folder is being executed?

This is because they are different programs with the same name

Could the JProc.class files be the same in the two folders?

No i checked this many times and the .class files are different but they have the same name in different folders

What happens if you rename the .class file you don't want executed to say .xxx and then execute the java command?

If the .class files have different names then this error of mine does not occurs at all

The line you posted
doesn't have the program name on it? How does it work w/o that?

The class name is JTim.class at its at the end of the command line without the .class

As Norm suggested - try it with the "JTim" left off ... finish with the "JProc\"

When i do this things get even worse and the program is never run at all with
the java intrepreter saying it does not know which is the main class to run

I find this very weird as i have never experienced anything like this before

Any help is greatly appreciated

Yours Sincerely

Richard West
freesoft_2000 at 2007-11-11 22:44:32 >
# 6 Re: ClassPath
What is motivating you to name classes this way? Is this some kind of version control?

Perhaps it is time to change the structure of your directories, or your file names, until you hit on a "final" version, then do your final builds.
nspils at 2007-11-11 22:45:36 >
# 7 Re: ClassPath
Hi everyone,

What is motivating you to name classes this way? Is this some kind of version control?

There's no motivation. Its something i stumbled upon and found very weird and was thinking it was somethin wrong i was doing but it seems weird that the intrepreter would react in this way. Its not part of any version control.

Perhaps it is time to change the structure of your directories, or your file names, until you hit on a "final" version, then do your final builds.

Perhaps you are right about this and i have to have different names for all my classes.

Richard West
freesoft_2000 at 2007-11-11 22:46:40 >
# 8 Re: ClassPath
Richard -

Have you organized this project into packages? If so, what is/are the name(s) of the package(s)? Any cross-over with your directory structure?
nspils at 2007-11-11 22:47:37 >