• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cannot resolve symbol

 
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1325
Android Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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;
 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try this

 
bhuvan sundar
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tried that too..Still getting the same error :-(
 
Prabhu Venkatachalam
Ranch Hand
Posts: 502
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
He's dead Jim. Grab his tricorder. I'll get his wallet and this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic