Results 1 to 7 of 7
Thread: Folders to group source files
- 03-31-2011, 04:49 AM #1
Member
- Join Date
- Jan 2011
- Posts
- 67
- Rep Power
- 0
Folders to group source files
I'm starting to have more source files than is easily managed and was wondering if it's possible to put the .java files into sub-folders of the package folder they are already in?
I'm using eclipse if that makes a difference.Currently developing Cave Dwellers, a Dwarf Fortress/Minecraft style game for Android.
- 03-31-2011, 04:53 AM #2
- Join Date
- Jan 2011
- Location
- Richmond, Virginia
- Posts
- 3,069
- Blog Entries
- 3
- Rep Power
- 7
You would have to change how you package them.
For example
imports the source files in the java/awt folder, but none of the subdirectories in there.Java Code:import java.awt.*;
Imports the source files in java/awt/event folder.Java Code:import java.awt.event.*;
- 03-31-2011, 05:12 AM #3
Member
- Join Date
- Jan 2011
- Posts
- 67
- Rep Power
- 0
Thought that might be the case :(. Will that mean that they wont be displayed as a tree/hierarchy in the "Package Explorer" of eclipse? The current packages I have don't seem to display that way and it would make things a little less readable if I can't see the hierarchy at a glance :(.
C++ spoiled me rotten with all it's niceties so I get a little disappointed when Java lacks the same features. Oh well, at least it'll be better than it currently is, thanks for the quick reply :)Currently developing Cave Dwellers, a Dwarf Fortress/Minecraft style game for Android.
- 03-31-2011, 05:26 AM #4
Senior Member
- Join Date
- Aug 2009
- Posts
- 2,388
- Rep Power
- 6
You should really have been using packages from the first class that you wrote. They explain how to use them here: Creating and Using Packages (The Java™ Tutorials > Learning the Java Language > Packages)
You've probably not defined your folders as source folders for your project in Eclipse. This has less to do with Java but more with your ability to use eclipse. Eclipse also has different types of viewing your projects according to your preference.
Nah, this doesn't really have anything to do with Java lacking features. There is nothing to suggest that source code organization is better in C++ than in Java.
- 03-31-2011, 05:32 AM #5
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
- 03-31-2011, 08:06 AM #6
Member
- Join Date
- Jan 2011
- Posts
- 67
- Rep Power
- 0
I'm using a few packages already but they are just the ones that were created automatically when I created the project. The project started off as just a test to see that my idea was actually viable on the Android platform and as each part proved viable I just kept coding more parts so I wasn't really expecting to get this far when I started and as a result I didn't expect to run into this problem. Normally I would have used some sort of namespacing before I got to this point but I didn't think it was going to be necessary. I'll probably start up a new project for this soon and sort out the packages when copying the code across to it, along with any other refactoring that might be beneficial.
Anyway thanks for the link, saves me having to look it up :D
Awesome, that's going to neaten things up heaps, thanks :D.Currently developing Cave Dwellers, a Dwarf Fortress/Minecraft style game for Android.
- 03-31-2011, 08:20 PM #7
Moderator
- Join Date
- Feb 2009
- Location
- New Zealand
- Posts
- 4,561
- Rep Power
- 11
Similar Threads
-
Searching directories for folders and .txt files
By XDrew574X in forum New To JavaReplies: 1Last Post: 03-29-2011, 09:41 PM -
Configuring Java source folders for eclipse
By kfir.wolfson@gmail.com in forum EclipseReplies: 8Last Post: 10-01-2010, 12:11 PM -
java isDirectory() is not detecting that my folders are folders!
By seandingobat in forum New To JavaReplies: 4Last Post: 10-10-2009, 12:26 AM -
Same source file but different source folders for different build configurations?
By m3anman in forum EclipseReplies: 0Last Post: 01-29-2009, 10:43 AM -
can java.io.File create a list of all files and folders.
By MattStone in forum New To JavaReplies: 20Last Post: 12-17-2007, 03:20 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks