Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #9198

Re: Unable to use package...why ???

From Nigel Wade <nmw-news@ion.le.ac.uk>
Newsgroups comp.lang.java.programmer
Subject Re: Unable to use package...why ???
Date 2011-10-26 09:55 +0100
Message-ID <9gq07mF3mtU1@mid.individual.net> (permalink)
References <280344ac-b398-44b3-b775-e84859feb5f0@gy7g2000vbb.googlegroups.com> <9gne1vFvskU1@mid.individual.net> <02de641c-1c6a-420b-b059-c17444e1ff3e@g25g2000yqh.googlegroups.com> <9gnn4cFbaqU1@mid.individual.net> <j86i64$j5u$1@dont-email.me>

Show all headers | View raw


On 25/10/11 15:47, markspace wrote:
> On 10/25/2011 5:07 AM, Nigel Wade wrote:
>> On 25/10/11 12:10, PortisHead wrote:
>>>
>>> java -cp c:\myclasses Showbcard
>>>
>>
>> That classpath only contains the location of the Getbcard class. It does
>> not include the location of Showbcard. Hence java cannot locate the
>> Showbcard.class file.
>
>
>
> Specifically, you said you put Showbcard in \examples, not \myclasses.
>
> java -cp c:\myclasses;c:\examples Showbcard
>
> I don't know how your previous claim that you compiled Showbcard with
> the class path of c:\myclasses worked. I think there's a mistake in the
> sequence of events you showed us.
>
>

I think the compilation should work because javac locates source files 
by normal file paths. It doesn't use the classpath to locate the java 
source files, only the supporting class files. So if you specify the 
command (as in the OP):
  javac -cp c:\myclasses Showbcard.java

it will compile the Showbcard.java source file in the current directory 
(no path), and attempt to locate any required classes via the supplied 
classpath.

OTOH java only uses class files, and similarly locates them via the 
classpath. The supplied classpath in the OP does not include the current 
directory (as I've already stated twice) so Showbcard.class cannot be found.

-- 
Nigel Wade





-- 
Nigel Wade

Back to comp.lang.java.programmer | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-25 00:06 -0700
  Re: Unable to use package...why ??? Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-10-25 10:32 +0100
    Re: Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-25 04:10 -0700
      Re: Unable to use package...why ??? Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-10-25 13:07 +0100
        Re: Unable to use package...why ??? markspace <-@.> - 2011-10-25 07:47 -0700
          Re: Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-25 15:03 -0700
            Re: Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-25 15:10 -0700
              Re: Unable to use package...why ??? Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-26 00:06 +0000
                Re: Unable to use package...why ??? Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-26 00:08 +0000
              Re: Unable to use package...why ??? Martin Gregorie <martin@address-in-sig.invalid> - 2011-10-26 00:06 +0000
          Re: Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-25 15:21 -0700
            Re: Unable to use package...why ??? markspace <-@.> - 2011-10-25 15:57 -0700
            Re: Unable to use package...why ??? Lew <lewbloch@gmail.com> - 2011-10-25 20:05 -0700
          Re: Unable to use package...why ??? Nigel Wade <nmw-news@ion.le.ac.uk> - 2011-10-26 09:55 +0100
            Re: Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-26 13:08 -0700
  Re: Unable to use package...why ??? Roedy Green <see_website@mindprod.com.invalid> - 2011-10-27 07:20 -0700
  Re: Unable to use package...why ??? Lew <lewbloch@gmail.com> - 2011-10-27 07:33 -0700
    Re: Unable to use package...why ??? PortisHead <massivetdm850@gmail.com> - 2011-10-28 12:57 -0700

csiph-web