How do I link an external .jar into my Xcode java project? That is, have it in the classpath during compilation and execution. I'm using Xcode 3.0 and this seems to have changed since 2.4.
3 Answers
In Xcode 3.1.2
Checking in file build.xml we see:
<!-- lib directory should contain any pre-built jar files needed to build the project
AppleJavaExtensions.jar is included to allow the built jars to run cross-platform if you depend on Apple eAWT or eIO classes.
See http://developer.apple.com/samplecode/AppleJavaExtensions/index.html for more information -->
<fileset id="lib.jars" dir="${lib}">
<include name="**/*.jar"/>
</fileset>
okay so, copy the external jar by hand into projectName/lib and compile. (Maybe clean first)
Edit: I had to copy the jar by hand, Xcode would not put it in the right place

- 8,762
- 3
- 39
- 50

- 1,760
- 16
- 28
Xcode 3.1 (I'm not certain about 3.0) uses an ant buildfile in its Java project templates. There's a ton of documentation out there on Ant. To change the classpath used when actually running the compiled code, edit the executable and add in an argument -classpath path/to/lib

- 2,216
- 14
- 16
I don't have a Mac to hand, but what if you drop the jar file into your ~/Library/Java/extensions (IIRC) folder?
Edit: I presume that you are using Mac OS X specific Java libraries, hence your use of Xcode? Otherwise I would recommend Eclipse. Actually I'd be willing to bet that Eclipse can use the Mac OS X specific Java APIs as well...

- 8,762
- 3
- 39
- 50

- 17,476
- 5
- 50
- 60