aspose file tools*
The moose likes Beginning Java and the fly likes stange problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "stange problem" Watch "stange problem" New topic
Author

stange problem

Arpana Rai
Ranch Hand

Joined: Nov 12, 2002
Posts: 93
there are 2 classes demo and demo.when i compile demo1 class it gives compiler error: cannot resolve symbol demo.
can some1 explain me this strange behaviour.
class demo
{
demo()
{
System.out.print("demo");
}

}
class demo1 extends demo
{
demo1()
{
System.out.print("demo1");
}
public static void main(String args[])
{
demo d=new demo();//1 compiler errorr
}
}

Thanx in advance
Rgds,
Arpana


SCJP1.4(91%)
eammon bannon
Ranch Hand

Joined: Mar 16, 2004
Posts: 140
Neither classes belong to a package, so they will need to be in the same folder to compile.
Arpana Rai
Ranch Hand

Joined: Nov 12, 2002
Posts: 93
I kept them in the package Arps even then its giving the same kinda error.
package Arps;
class demo1 extends demo
{
demo1()
{
System.out.print("demo1");
}
Static demo d;
public static void main(String args[])
{
d=new demo();
}
}
-----------------------------------
package Arps;
public class demo
{
public demo()
{
System.out.print("demo");
}
public static void main(String []args)
{
demo d=new demo();
}
}

rgds,
Arpana
Jeff Langr
author
Ranch Hand

Joined: May 14, 2003
Posts: 762
Make sure the demo class is stored in a source file named demo.java. If you named it Demo.java, for example, the compiler will not find it--it looks for "demo.java."
The generally accepted Java style convention is to name classes starting with uppercase letters. Instead of "demo" please use "Demo."
-Jeff-


Books: Agile Java, Modern C++ Programming with TDD, Essential Java Style, Agile in a Flash. Contributor, Clean Code.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

and you need a folder Arps;
but packages should be in lowercase letters, so call it 'arps'.
Put you java into that arps-folder.
compile it from above:
javac arps/Demo.java
and use the [ code ] button when posting code.
[ April 01, 2004: Message edited by: Stefan Wagner ]

http://home.arcor.de/hirnstrom/bewerbung
Arpana Rai
Ranch Hand

Joined: Nov 12, 2002
Posts: 93

package arps;

class Demo
{
public Demo()
{
System.out.print("Demo");
}
public static void main(String []args)
{
Demo d=new Demo();
}
}


package arps;
class Demo1
{
static Demo d;
Demo1()
{
System.out.print("Demo1");
}
public static void main(String args[])
{
d=new
Demo();
}
}

I followed all the above instructions.When i compile the demo class it gives error that "cannot read arps/Demo.java.
Is there any classpath problem???
rgds,
Arpana
jamma jacob
Greenhorn

Joined: Mar 22, 2004
Posts: 12
Yes I feel it is classpath problem.Be in the package just before the arps
package ie c:arpana/arps/....be in the arpana pack and compile with arps.demo.java
[ April 01, 2004: Message edited by: red bull ]

SCJP 1.2
Arpana Rai
Ranch Hand

Joined: Nov 12, 2002
Posts: 93
It still giving the same kinda error.
jamma jacob
Greenhorn

Joined: Mar 22, 2004
Posts: 12
Hi
Arpana
Try this, take away u r class path settings put the java files in bin folder and compile.So we can check whether its a class path problem
Arpana Rai
Ranch Hand

Joined: Nov 12, 2002
Posts: 93
I unset the CLASSPATH variable.now its working.
thanx bull
rgds,
Arpana
jamma jacob
Greenhorn

Joined: Mar 22, 2004
Posts: 12
Hi
Arpana
It wasn't a strange problem



rgrds
red bull
 
jQuery in Action, 2nd edition
 
subject: stange problem