My question is simple: what is the best place to store all my jar's, gwt and other frameworks on mac os x ?
I thought that it is /Library/Java/Extensions
.
But I'm not sure that it is correct.
The /Library/Java/Extensions directory can be used for additional jar files or JNI libraries that need to be placed on the system classpath. For more controlled access, the ~/Library/Java/Extensions directory can be used for user-level installation of support libraries.
For Windows, the JDK extension directory is located at " <JAVA_HOME>\jre\lib\ext " (e.g., " c:\Program Files\Java\jdk1. 8.0_xx\jre\lib\ext "). For Mac, the JDK extension directories are " /Library/Java/Extensions " and " /System/Library/Java/Extensions ".
There are two ways to install java stuff:
As a sample, here is how MacPorts installs Tomcat:
/Library/LaunchDaemons/blah.blah.start.Tomcat.daemon
/opt/local/etc/LaunchDaemons/blah.blah.plist
/opt/local/bin/start-tomcat-script
/opt/local/share/docs/...tomcat docs
/opt/local/share/java/...tomcat classes
You don't want to mimic that manually because it's an insane amount of work and there is no benefit. You either sudo port install tomcat6
or uncompress the whole Tomcat in /Users/YOURUSER/java/apache/tomcat/6/
and add bin to the path. Same thing for SDKs.
If you want to install just jars (not SDKs), use Maven as much as you can. You said something about trouble adding to your local repository. That's not correct, you can have several repositories and enable/disable them per project. I have one for the stuff maven downloads, and another one where I manually add things. If you are the only user of your machine put the repo somewhere inside your home, otherwise use /opt/local/var/
or anywhere you like.
Don't overthink it, it's about you getting work done.
Your .m2 repository? Are you not using Maven for resolving your dependencies?
It is a very bad idea to install libraries in system folders, as it will influence all Java programs running on your computer, and may conflict with other libraries carried properly along by the individual programs.
A much better approach is to create executable/runnable jars in which the Class-Path attribute points to the jars you need.
Normally, you'd want to store libraries in the projects that use them rather than at the system level. Using a technology such as Maven would be an excellent way to do this.
UPDATE: Now that I know you're using maven, the suggestion changes a bit. I understand that you don't want to just manually install libraries into your local repository, which makes sense. My response would be that this is a LOT cleaner than dumping them in some global library folder. (And you avoid getting all of the anti-LD_LIBRARY_PATH people up in arms :) ).
Another thought would be to setup your own maven repository and keep your libraries there.
It really comes down to what you are trying to do. Do you just want to write some code that'll never leave your box or do you want a nice portable solution or what? We definitely need a bit of context.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With