• Post Reply Bookmark Topic Watch Topic
  • New Topic

cannot resolve symbol  RSS feed

 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Please help me in solving the following:



I compile these java files using javac -d .
C:\>javac -d . HelloIF.java
No error
C:\>javac -d . HelloImpl.java

HelloImpl.java:3:cannot resolve symbol
symbol : class HelloIF
location: package hello
public class HelloImpl implements HelloIF

1 error


thanks
 
Muhammad Saifuddin
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by bhuvan sundar:






make sure your interface and class file are in same folder before compilation..

just now i run your code in JCreater and its running ok with out any error..

hope this help
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
javac -d . HelloImpl.java



In this "." refers to current directory and you are telling compiler that HelloImpl.java is in current directory. But it isn't.

So, Change your directory to wherever your java files are in your prompt and use this command:

javac -d . *.java;
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Prabhu venkatachalam:


javac -d . HelloImpl.java

In this "." refers to current directory and you are telling compiler that HelloImpl.java is in current directory. But it isn't.



Just to avoid confusion for any other newbies reading this at a later date, the '-d .' has nothing to do with the location of the source files. It specifies where the class files will be created.
The location of source files is specified with the -classpath option.
[ November 17, 2006: Message edited by: Joanne Neal ]
 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Posted by Saif Uddin
make sure your interface and class file are in the same folder before compilation

They are in C drive. The same code when run in Eclipse works fine. I've problem only when i use command prompt.

Does this have anything to do with classpath? The interface file is compiled and package is created without any problem. When I try to compile the implementation file, I get the error.
[ November 17, 2006: Message edited by: bhuvan sundar ]
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this

 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tried that too..Still getting the same error :-(
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
Java jQuery Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I tried in my machine at it is working fine in command prompt as well as Eclipse.

This is just a trial and error way:

Try compling again by deleting all the files in c:/>hello directory except Java file with my command I mentioned above.
 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well..this worked out..but, now, the class files are placed in a directory called hello within hello folder. So, when i try to run the class as
C:\>java HelloImpl,
I get the error
Exception in thread "main" java.lang.NoClassDefFoundError : HelloImpl

But when I run as

C:\>java hello.HelloImpl

I get the output. How to avoid this?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!