-1

I'm using Eclipse on a Mac. I want to write a method that creates a bar chart. To do this I need to use Bar.java class which I have downloaded and added as an external class folder. When I reference the class in my method it it not recognized. I have had this trouble with other classes in the past.

This is the error I receive:

Exception in thread "main" java.lang.Error: Unresolved compilation problems: 
    Bar cannot be resolved to a type
    Bar cannot be resolved to a type

    at TaxChart.main(TaxChart.java:5)

Bar.java is in a folder located at /Desktop/class/ I have referenced it using configure build path and add external class folder.

Deduplicator
  • 44,692
  • 7
  • 66
  • 118
calmcalmuncle
  • 143
  • 1
  • 2
  • 16
  • Are you pointing to the folder Bar.java is in? Or the folder that Bar.class is in? (Should be Bar.class) – OtherDevOpsGene Oct 29 '14 at 15:23
  • 1
    ..you did compile `Bar.java` into `Bar.class`, right? – Qwerky Oct 29 '14 at 15:24
  • sorry, i am new to java, the last time this problem occurred i then tried it on a windows machine and it worked straight away. could you tell me what i am doing wrong in a little more detail? thanks! – calmcalmuncle Oct 29 '14 at 15:40

1 Answers1

0

External file have different package structure and hence it won't compile. Try to import that class in your project and fix compilation issues first and then try to use in your application. It should work.

Chirag Shah
  • 55
  • 1
  • 10
  • i am unable to find a solution to this? could you walk be through the steps from compiling bar.java to bar.class? – calmcalmuncle Oct 29 '14 at 15:50
  • It's a single source file. Copy it into your source folder. – nitind Oct 29 '14 at 16:11
  • Check this for how to compile java file to class file in eclipse: http://stackoverflow.com/questions/4058155/how-can-i-compile-a-java-program-in-eclipse-without-running-it – Chirag Shah Oct 29 '14 at 19:00