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.
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...
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
In x-code 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, X-Code would not put it in the right place
I too am confused by this. I have recently downloaded j2ssh and wanted to use it in my application. I created a project with xcode but can't get it to run due to the necessity of the jar files.
I added the line:
import j2ssh.*;
to my java source I tried to copy the jar files into the lib directory of the project but I still end up with link errors and package j2ssh does not exist.
I wonder if its because the jar files have names like j2ssh-common-0.2.9.jar j2ssh-daemon-0.2.9.jar j2ssh-ant-0.2.9.jar j2ssh-core-0.2.9.jar
Maybe I should have added: import j2ssh-common-0.2.9; to my source code.
or maybe I should have copied the jar files to some other /Library/Java/Extensions or maybe I should have modified the build.xml file some how...
Grrr... so frustrated... HELP!