The file compiles and works as expected but when I try to use it in another file it keeps saying when I attempt to compile. So clearly I don't know how to import code from another file correctly. How do I import the file for use within , I have read many explanations but they all require an IDE which I don't plan on using, I am using notepad++.
1 Answer
You do import ReadFile.*; but ReadFile is not the package name but the class name.
Package allows you to categorize your classes. Take a look at http://en.wikipedia.org/wiki/Java_package for more details.
Put your ReadFile.java into a package (for example: package org.your-company.io) then in the second class:
import org.your-company.io.ReadFile;
The instruction import somepackage.* indicates that you can use any classes from the package somepackage in your current class.
For example, if I do:
import java.sql.*;
I will be able to call, in my code, directly:
Date dsql = ... // java.sql.Date
DriverManager driver = ... // java.sql.DriverManager
etc.
Edit
As Dukeling mentionned in a comment, if your classes are in the same "folder" (I mean package), you can remove your instruction import ReadFile.* which is wrong and useless.
importstatement onCentralizeclass, its looking for package.