Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #9283
| From | PortisHead <massivetdm850@gmail.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: Unable to use package...why ??? |
| Date | 2011-10-28 12:57 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <089aebad-fdec-491e-afb6-ce32d30b5029@eh5g2000vbb.googlegroups.com> (permalink) |
| References | <280344ac-b398-44b3-b775-e84859feb5f0@gy7g2000vbb.googlegroups.com> <7180194.1172.1319726029502.JavaMail.geo-discussion-forums@prib32> |
On Oct 27, 5:33 pm, Lew <lewbl...@gmail.com> wrote:
> PortisHead wrote:
> > First I created the file : Getbcard.java
> > inside the directory : C:\myclasses\exam\test\dok
> > below is the script :
> > package exam.test.dok;
>
> "myclasses" is the root of the classpath for this class. Directories that match up with packages descend from such a root.
>
> > public class Getbcard
> > {
> > public void setname()
> > {
> > System.out.println("Hello");
> > }
> > }
>
> > then , I compiled it using this command line:
> > javac Getbcard.java
>
> From what directory? Where is your "exam/test/dok/" directory path? ("exam\test\dok" in Windows.)
From the same directory.That is -----> C:\myclasses\exam\test\dok
>
> > and got the appropriated .class file:
> > Getbcard.class
>
> In what directory?
In the same as above --->C:\myclasses\exam\test\dok
> > Next , I created a new file , named : Showbcard.java in folder : C:
> > \examples
>
> That sounds like a class with no package. Do not mix classes in packages with classes in the "no-package" (the default package, which isn't really a package).
>
> <http://download.oracle.com/javase/tutorial/java/concepts/package.html>
>
> Packages have to match with directories, in the normal filesystem approach. If they do not, you are fubared.
>
> > below is the script :
>
> Not a script.
>
>
>
>
>
>
>
>
>
> > import exam.test.dok.*;
> > public class Showbcard
> > {
> > public static void main(String[] args)
> > {
> > System.out.println("Showbcard");
> > Getbcard i = new Getbcard();
> > i.setname();
> > }
> > }
>
> > then , I compiled it using this command line:
> > javac -cp c:\myclasses Showbcard.java
> > and got the appropriated .class file:
> > Showbcard.class
>
> In what directory?
the Directory was ----> C:\examples
>
> > Now when I try to execute the file like :
> > java -cp c:\myclasses Showbcard
>
> > I get the error : Could not find or load main class Showbcard
>
> > What am I doing wrong here ?
>
> As mentioned upthread, you left out the package in the class for the "java" command.
>
> <http://download.oracle.com/javase/tutorial/java/package/index.html>
> <http://download.oracle.com/javase/tutorial/java/package/managingfiles...>
>
> Note: Do not use the CLASSPATH variable. Stick with the "-jar" or "-cp" options to set classpath.
>
> <http://download.oracle.com/javase/7/docs/technotes/tools/index.html>
> <http://download.oracle.com/javase/7/docs/technotes/tools/windows/java...>
> <http://download.oracle.com/javase/7/docs/technotes/tools/windows/java...>
>
> --
> Lew
Thanks again Lew for all the suggestions !!!
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Find similar
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