Cero
|
 |
«
Posted
2009-04-12 22:47:11 » |
|
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 ?
|
|
|
|
bienator
Senior Devvie   
OutOfCoffeeException
|
 |
«
Reply #1 - Posted
2009-04-13 00:20:25 » |
|
the standard NetBeans ANT driven java project has the following structure:
<project name>/ ./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
|
|
|
|
Mr_Light
|
 |
«
Reply #2 - Posted
2009-04-14 14:05:48 » |
|
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)
|
It's harder to read code than to write it. - it's even harder to write readable code.
The gospel of brother Riven: "The guarantee that all bugs are in *your* code is worth gold." Amen brother a-m-e-n.
|
|
|
Games published by our own members! Check 'em out!
|
|
Cero
|
 |
«
Reply #3 - Posted
2009-04-14 15:36:49 » |
|
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  
|
|
|
|
Cero
|
 |
«
Reply #4 - Posted
2009-04-14 15:37:49 » |
|
btw I would also use Eclipse but I thought it would be even harder to set up =P
|
|
|
|
Json
Junior Devvie   Exp: 7 years
|
 |
«
Reply #5 - Posted
2009-04-14 15:41:09 » |
|
I'm no Netbeans user myself but I'd have thought you should put your com folder in the src directory.
// Json
|
|
|
|
Cero
|
 |
«
Reply #6 - Posted
2009-04-14 16:24:53 » |
|
nah I tried that multiple times... remember there are only class files in it
like it is shown in the screenshot
|
|
|
|
Jackal von ÖRF
|
 |
«
Reply #7 - Posted
2009-04-14 17:08:36 » |
|
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.)
|
|
|
|
bienator
Senior Devvie   
OutOfCoffeeException
|
 |
«
Reply #8 - Posted
2009-04-14 17:30:00 » |
|
main problem is i just cannot include my com folder, my additional packages, which are not jars
i don't understand. "Add Jar/Folder" to compile classpath in project properties doesn't work for you?
|
|
|
|
Gudradain
|
 |
«
Reply #9 - Posted
2009-04-14 19:48:20 » |
|
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.
|
|
|
|
Games published by our own members! Check 'em out!
|
|
h3ckboy
|
 |
«
Reply #10 - Posted
2009-04-14 19:53:13 » |
|
hehe, this is another example of why little IDE are good.
the smaller the easier, granted less organized, but still easier.
|
|
|
|
Gudradain
|
 |
«
Reply #11 - Posted
2009-04-14 20:35:43 » |
|
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.
|
|
|
|
h3ckboy
|
 |
«
Reply #12 - Posted
2009-04-14 20:45:23 » |
|
ignorance is bliss 
|
|
|
|
Hsaka
|
 |
«
Reply #13 - Posted
2009-04-14 22:17:38 » |
|
You will need to wrap up your com folder (with the .class files) in a jar file as suggested here: Zip the .class files (so that the "com" directory is in the root) and rename the .zip into .jar. Then just import the jar file into your netbeans project. 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. You can't do this because the .class files produced in the build folder are a result of the compile process.
|
|
|
|
Cero
|
 |
«
Reply #14 - Posted
2009-04-14 22:30:32 » |
|
hehe, this is another example of why little IDE are good.
the smaller the easier, granted less organized, but still easier.
Absolutely. i don't understand. "Add Jar/Folder" to compile classpath in project properties doesn't work for you? Nope, look what happens  Also I tired putting it in the build folder aswell but I also doesn't work x)
|
|
|
|
Cero
|
 |
«
Reply #15 - Posted
2009-04-14 22:41:55 » |
|
ok I just tried the same just by zipping it as jar and know it works... I fail to see the point =)
|
|
|
|
cylab
|
 |
«
Reply #16 - Posted
2009-04-14 22:54:02 » |
|
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.
|
Mathias - I Know What [you] Did Last Summer!
|
|
|
Cero
|
 |
«
Reply #17 - Posted
2009-04-15 00:03:21 » |
|
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
|
|
|
|
Gudradain
|
 |
«
Reply #18 - Posted
2009-04-15 00:08:08 » |
|
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.
|
|
|
|
Cero
|
 |
«
Reply #19 - Posted
2009-04-15 01:18:56 » |
|
Now I get it, thanks
|
|
|
|
|