Switching to a real IDE (NetBeans) help me =)

Even tho my project is pretty elaborate, I took JCreator till now
Now I wanna switch to NetBeans.
Only problem is with the packages

I have 3 packages, folder with class files which should be imported

all my project java and class files are in the same directory, and in that same directory there are of course directories containing game content and the packages I need. Those are in a directory called “com” as it is done often.

So I have this com directory in which everything is included and fine, and it works in JCreator of course, but in NetBeans I cannot make him understand that he should use them / I dont know where to put them.

He goes on like package xy doesnt exists

one example of course is in my OggClip class “import com.jcraft.jogg.Packet;”
something like that

… how you do this in a real IDE ?

the standard NetBeans ANT driven java project has the following structure:

/
./src (contains .java source files, may also contain content (images etc))
./build (destination folder for .class files and everything else you need to run the app, managed automatically)
./dist (destination folder for a full project build e.g jar, pack, sign etc)
./nbproject (build script and project properties)
./lib (additional jars)

NetBeans will automatically copy all files from src to the build folder except those on the ignore list (default on the list is .java and .form).

To successfully build your project in NetBeans with similar results like before you should try the following steps:

  1. copy your sources (java, images etc) to the src folder
  2. remove all .class files in the src folder (this one is important)
  3. right click on the project -> Build -> Packaging -> remove **/*.java, in the “Exclude from jar file text field”
  4. build your project

step 3 is only needed if you really want to ship your java source files side by side with your class files.

if you have your data in a separate folder just add this folder as additional source folder to the project (again via project properties window). From now on the content in the data folder should be automatically copied to the build dir on build and therefore also bundled in the jar.

hope that helps

Since visualvm I pretty much haven’t used netbeans perhaps a gui mockup here and there, anyway

Isn’t there a import project thing or add folders as source folder…

I’d be surprised if netbeans wouldn’t be able to adapt to your own directory structure…

If all else fails define a pom.xml with your directory structure and use netbeans maven support (I’ve heard it’s excellent)

main problem is i just cannot include my com folder, my additional packages, which are not jars

I put it now for exmaple in the lib folder, but of course it didn’t help

where exactly do I have to add those folders, or just the com folder whatever

http://img529.imageshack.us/img529/3747/nb1.png

http://img529.imageshack.us/img529/580/nb2.png

btw I would also use Eclipse but I thought it would be even harder to set up =P

I’m no Netbeans user myself but I’d have thought you should put your com folder in the src directory.

// Json

nah I tried that multiple times… remember there are only class files in it

like it is shown in the screenshot

Zip the .class files (so that the “com” directory is in the root) and rename the .zip into .jar. That’s how libraries are usually used. (Maybe NetBeans supports also unpacked libraries, at least IDEA does, but if it doesn’t seem to work, don’t waste too much time in getting it to work.)

i don’t understand. “Add Jar/Folder” to compile classpath in project properties doesn’t work for you?

If you want to use .class they need to be in the build folder. So if you put all your stock in the build folder than press compile it will probably work. Unfortunately, in the build folder they are not permanent because all the build folder get clear when you click “Clean and build main project”, that mean you need to manually reput your stock in it…

But really, the “Add jar/folder…” command when you right click on the Libraries folder in the project work great. Use it.

hehe, this is another example of why little IDE are good.

the smaller the easier, granted less organized, but still easier.

I first learn java with DrJava and I thought at this time that it was the best tool to code. But now I’m using Eclipse and Netbeans and there is no way I will go back to DrJava.

ignorance is bliss 8)

You will need to wrap up your com folder (with the .class files) in a jar file as suggested here:

[quote]Zip the .class files (so that the “com” directory is in the root) and rename the .zip into .jar.
[/quote]
Then just import the jar file into your netbeans project.

[quote]If you want to use .class they need to be in the build folder. So if you put all your stock in the build folder than press compile it will probably work.
[/quote]
You can’t do this because the .class files produced in the build folder are a result of the compile process.

Absolutely.

Nope, look what happens

http://img18.imageshack.us/img18/6480/nb3.png

Also I tired putting it in the build folder aswell but I also doesn’t work x)

ok I just tried the same just by zipping it as jar
and know it works… I fail to see the point =)

You just would have needed to add the folder with the class files (the one above the com folder) as a library via the project properties [Add Jar/Folder] button in the libraries category. That’s all.

I did exactly that. With the folder it just wouldn’t work, but as a jar it did

The problem was probably that you put the com folder directly in the lib. You need to put the com in another folder then putting this folder in the lib.

By making a jar you basically did the same thing.

Now I get it, thanks