Question

I want to ask smaller question about Java VM and thing about it.

If I understand import process correctly, then when I request contents of packages by import keyword in Java, packages are being imported from it's specified import directory. Then when I'm running Java application from a directory in computer and some of the imported packages could not be found in JVM import directory, JVM is looking for them in current directory. But in that case something must be wrong, because when I run my project from Eclipse and I request some package from the project, it's found. I think that Eclipse is changing directory where packages are being searched. Am I right? Is this all way of importing in Java?

Était-ce utile?

La solution

The import statement is just syntactic sugar so you don't have to specify the fully qualified name everywhere in your classes. It doesn't actually import anything in terms of code.

Classes are looked up in the classpath.

Autres conseils

In eclipse you can configure the build path (for each project) option project - - > build path. There you can either add a directory, jar file, external jar files, etc. Also you can check what's already defined.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top