-1

I have a java file at:

new File("C:/programs/java/folder")

Which is a random directory on my computer. How can I import the file at this directory? I have already tried:

import "C:/programs/java/folder";
import C.programs.java.folder;
import C:/programs/java/folder;

but none of these work. How can I import a java file at a specified directory?

Nateguana
  • 59
  • 1
  • 6
  • 2
    No, you can't. That's not how Java works. Learn the basics. What is an import. What is a package. What is the classpath. Read a book. Don't try random things. – JB Nizet Mar 04 '18 at 17:16
  • 1
    You can only import classes using their full.package.ClassName. But location holding package structure of that class needs to be present in *classpath*. So you will need to compile and run with -classpath (or -cp) parameter which will hold package locations or JARs. – Pshemo Mar 04 '18 at 17:19
  • No It's wrong. refer this for get understand about file import https://stackoverflow.com/questions/2903166/meaning-of-the-import-statement-in-a-java-file – Poorna Senani Gamage Mar 04 '18 at 17:32

1 Answers1

-2

You have to import the jar file into the Build Path. On Ecipse rigth click into the project folder, Build Path, Add Libraries.

Joan
  • 1