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.

Andrea
  • 11,801
  • 17
  • 65
  • 72
Bobby
  • 18,217
  • 15
  • 74
  • 89

1 Answers1

2

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
  • 12,000
  • 7
  • 52
  • 73
  • 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. – amara Sep 26 '10 at 00:41
  • But - rereading, that sounds like I disagree with Tony. He has a good answer! I am (mostly) in agreement with him. – amara Sep 26 '10 at 00:42
  • 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. – Bobby Sep 26 '10 at 00:51
  • @Vuntic - re your *"... but come on ..."* - Java has these conventions like this for a reason. Why wantonly / gratuitously violate them? – Stephen C Sep 26 '10 at 01:01
  • @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. – amara Sep 26 '10 at 04:31
  • 1
    @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. – amara Sep 26 '10 at 04:32
  • @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 Sep 26 '10 at 04:46
  • @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 Sep 26 '10 at 04:47
  • @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. – amara Sep 26 '10 at 15:23
  • @Vuntic - sounds like you need to use an IDE – Stephen C Sep 26 '10 at 15:28
  • @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 Sep 26 '10 at 15:29
  • @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) – amara Sep 26 '10 at 15:33
  • @Tony - What if the code is being released, but it's a program that people just use as users, not developers? Like most games. – amara Sep 26 '10 at 15:35
  • @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 Sep 26 '10 at 15:45
  • hehe, my development environment isn't integrated. It's a pretty good development environment though ^_^ – amara Sep 26 '10 at 15:52