1

I have some classes in Eclipse which cannot be resolved to a type. I know that classes can be in .class, .jar, .par, .zip files. Are there any other file types that I have to look for? Or is there anything eclipse how I could make Eclipse recognize the classes?

In my general understanding, once I have found these files and added them to the classpath, the Eclipse should be able to recognize them.

Dávid Natingga
  • 839
  • 3
  • 13
  • 30
  • Answer Bowie was meant to be a comment. Can't delete on phone. I don't understand what you mean. Do you mean java classes? They should have a .java extension. – null Jul 16 '13 at 22:53

3 Answers3

2

Actually my colleague gave me an answer:

If the class cannot be found or resolved to a type within Eclipse, this is only the problem with build path. And to the build path, the files should be added of type as I have said: class, jar, par, zip; no other suffix is accepted.

Dávid Natingga
  • 839
  • 3
  • 13
  • 30
0

Maybe I am misunderstanding your question, so please excuse me if I am. Type resolution errors are often due to incorrect imports or misspellings. Ill give an example:

public class Foo extends Component{
//If you forgot to import java.awt.*; You would receive the error 
 "Component cannot be resolved to a type"
}

Also if you misspelled an extension you would get the same error.When you create a class in eclipse you need to create a new file for that class.

You should also post your code so we know exactly what you're talking about. I don't think your error has anything to do with the classpath. :)

moonbeamer2234
  • 351
  • 1
  • 3
  • 12
  • See my answer. I did not work with java standard library, so actually it was the case that some classes were not in the build path. – Dávid Natingga Jul 18 '13 at 04:43
0

Class path entry could be jar, zip or directory (source)

set CLASSPATH=classpath1;classpath2...

Class paths to the .jar, .zip or .class files. Each classpath should end with a filename or directory depending on what you are setting the class path to: For a .jar or .zip file that contains .class files, the class path ends with the name of the .zip or .jar file. For .class files in an unnamed package, the class path ends with the directory that contains the .class files. For .class files in a named package, the class path ends with the directory that contains the "root" package (the first package in the full package name). Multiple path entries are separated by semi-colons. With the set command, it's important to omit spaces from around the equals sign (=).

The default class path is the current directory. Setting the CLASSPATH variable or using the -classpath command-line option overrides that default, so if you want to include the current directory in the search path, you must include "." in the new settings.

Classpath entries that are neither directories nor archives (.zip or .jar files) nor * are ignored.

Mike
  • 20,010
  • 25
  • 97
  • 140