King koopa
King koopa

Reputation: 11

NetBeans importing classes package problems

I have created a class in Java that I need to import into NetBeans and use in a GUI. What I have done so far is add the jar file containing the classes to the library in my project. I can look inside the jar file and see the classes I need inside the . I have looked around online and know that the best to way import these classes is to move them to another package that isn't the .

My problem is that I do not know how to do this. I saw that I can create a package in netbeans, but it is gray when it appears and I can't seem to do anything with it. I basically have no idea how to create packages that I can use to import classes If someone could please walk me through step by step I would greatly appreciate it. I have looked at the other posts on this site and other places online, but they seem to skip over somethings I am not sure about. My teacher didn't mention anything about packages either, so I am really in the dark.

Upvotes: 0

Views: 3097

Answers (1)

Bastien Jansen
Bastien Jansen

Reputation: 8836

You can copy your source files (*.java) in your project's src folder, then use refactoring to change the package.

Right-click your java file, then select Refactor > Move and type your new package name.

Upvotes: 1

Related Questions