I'm a complete rookie with NetBeans, and that's unfortunate because this summer our Instructor wants us to use NetBeans throughout the entire course.

I'd just like to know... how do I add existing files to a project? I've tried right-clicking the project folders to see if there was some kind of add command. There were none, but then I simply tried creating a package to hold the projects and still no add project command. Not even in the File option or anywhere else.

It's not that I'm lazy and don't feel like finding the existing project/package in the source files, but I find it somewhat inconvenient to not be able to easily implement classes into one package or project in a Development Kit like NetBeans.

Is there any way to do what I'm asking, or am I SOL and must simply create a shortcut to the sourcefile folder where the projects and packages are located?

You want to add a library, or just source files to edit? If it is a library (.jar) or something, there should be an add external library option. But I think you want to add source files, you can just drag-drop or do it directly in the filesystem.

You want to add a library, or just source files to edit? If it is a library (.jar) or something, there should be an add external library option. But I think you want to add source files, you can just drag-drop or do it directly in the filesystem.

I created a package in my project manager and then tried opening a file to examine.

From there I tried clicking and holding the tab that had the class information and when i try to drop the file into the package it shows the NOT circle symbol. When I release the mouse, obviously nothing happens.

I found out that you can control the directory that the package is created in so I guess I'll try the second option and simply add the files directly to the package.

Ok that idea worked, but now I'm getting an issue with compiling. It says it cant find the files even through they're in the same package.

I've even tried adding the "package <packagename>" statement at the very top of the java files, but to no avail. What am I doing wrong?

Yeah, you will definitely need the package declarations. It is hard to tell what is going on though, so you have a specific error you can paste? (try google too).

Pretty much worked straight away for me. All I did was create a new project, delete the default package and copy in your package instead. DoodleBug.java was missing a package statement, but that was all...

You still having issues?

Comments
Thanks a million for your help!

Pretty much worked straight away for me. All I did was create a new project, delete the default package and copy in your package instead. DoodleBug.java was missing a package statement, but that was all...

You still having issues?

Can't yet because I'm copying NetBeans IDE to my iPod so I can take it with me wherever I go.

Once that's done I'll give it a shot.

Just run it like any other java file, from either the right-click menu or the Run menu. Netbeans will start it in the Applet Viewer.

Just run it like any other java file, from either the right-click menu or the Run menu. Netbeans will start it in the Applet Viewer.

I, mistakingly, found out how to do this via GUIFormExamples... to an extent.

In order to run as an Applet must I keep doing this and simply overload the init method for JApplet/Applet or is there something going on in the background that I don't know about?

I don't follow what you mean. If the class extends Applet or JApplet, it runs in the Applet viewer when you run or debug the file.

Comments
Hah! I figured it out. I kept trying to create an Applit from a new Project, and not an existing package! I'm such a nub!

When I open a new Project, how should I open it? Which option controls Applet-driven classes?

I tried your advice but whenever I make, oh say, a Java Application and decide to make the class extend Applet/JApplet, I get a <No class file> error when I attempt to run, even with the init method overridden and my class extends JApplet and I have no main method implementation.

What am I doing wrong? How should I be loading my projects when creating a new one?

I'm using NetBeans 6.1.

This question has already been answered. Start a new discussion instead.