views:

56

answers:

1

My file structure looks liked this:

cse408 - lib  
       - pics  
       - App.java  
       - ImageUtil.java  
       - Menu.java  

And to compile/run I use the following commands:

***To Compile***
LD_LIBRARY_PATH=/home/soldiermoth/Downloads/6.4.0/lib javac -classpath lib/jmagick.jar:. App.java
****************

****To Run******
LD_LIBRARY_PATH=/home/soldiermoth/Downloads/6.4.0/lib java -classpath lib/jmagick.jar:. App
****************

As you may be able to tell I have a dependency on an installed jmagick library where the jmagick.so file is in 6.4.0/lib

Mostly I'm wondering about how I'm handling dependencies and how I could do it better especially cross platform.

+2  A: 

It's more common to have source files under a source directory, and then in the package structure beneath that.

so I'd expect to see

cse408 - lib  
       - pics  
       - src
           App.java  
           ImageUtil.java  
           Menu.java 

At the very least. If your code is in the com.soldier.moth package, I'd expect

cse408 - lib  
       - pics  
       - src
           - com
               - soldier
                    - moth        
                        App.java  
                        ImageUtil.java  
                        Menu.java
Tony Ennis
Personally, I just have one base package; like "ukuku" instead of "com.mysite.ukuku". I'm well aware this is considered "bad practice," but, _come on_, I'm not going to have conflicts with another package named *ukuku* of all things.
Vuntic
But - rereading, that sounds like I disagree with Tony. He has a good answer! I am (mostly) in agreement with him.
Vuntic
That does make sense, I may change that aspect, but mostly I'm wondering about the handling of my dependency and have edited the question as such.
Soldier.moth
@Vuntic - re your *"... but come on ..."* - Java has these conventions like this for a reason. Why wantonly / gratuitously violate them?
Stephen C
@Stephen mhm. You know that Java's conventions are disregared in the JDK's code when they're too inconvenient, right? Tell me what specific reason we're talking about here.
Vuntic
@Stephen This is neither wanton not gratuitous. It saves time and trouble not having to deal with a silly com.xyz. prefix. Additionally, it is *so easy* to add it in if you later decide you need it.
Vuntic
@Vuntic - *"This is neither wanton not gratuitous."* - That is a matter of opinion. The way I see it, it is ZERO EFFORT to deal with a "silly" com.xyz prefix. But it would be seriously PAINFUL to deal with someone elses code that gave class name collisions due to their wanton and gratuitous breaking of the naming rules.
Stephen C
@Vuntic - *"it is so easy to add it in if you later decide you need it."* - Not if you've published the code (binaries), and someone else experiences the collisions.
Stephen C
@Stephen - So, use com.xyz prefixes if you have a package called "tuple" or something. No need to bother if you have something made-up like "ukuku". Zero effort? What about wrapping source in two extra folders? Navigating through them gets annoying after a while.
Vuntic
@Vuntic - sounds like you need to use an IDE
Stephen C
@both - I find it better to follow the 'principle of least surprise.' This means to follow convention unless there's a compelling reason to do otherwise. That being said, for the test snippets I write for this site, I have to admit I don't use a proper package - the code is never being released.
Tony Ennis
@Stephen IDEs... meh. I'm using Notepad++ - I've tried using the IDEs everyone says are great, like Eclipse, but I don't actually need to work with huge (several hundred thousand lines) projects, yet. Notepad++ has extremely useful features that your typical IDE doesn't. (I can't say what they are; it varies from IDE to IDE)
Vuntic
@Tony - What if the code is being released, but it's a program that people just use as users, not developers? Like most games.
Vuntic
@Vuntic haha I knew you weren't using an IDE. Otherwise you wouldn't have made the 'skipping folders' comment. I use IntelliJ - it's the bomb. I follow this particular convention because it seems ot have some value and costs me nothing. In any event, since you're the one doing the work you should please yourself.
Tony Ennis
hehe, my development environment isn't integrated. It's a pretty good development environment though ^_^
Vuntic