Xcode Confusion

blackoutspy

Registered
I am currently in college, and taking cs261 - Abstract Data Structures. Each week we have a program due. Our teacher has given us a "jds" file with classes that our programs will need to include. He said to add a CLASSPATH variable with your unix machine so the java compiler knows where those added classes are. I understand that part, but what i do not understand is how i could get that to carry over to Xcode. Aslo, when i create a blank project in Xcode (because i do not know what type of program under java i am developing) i can't compile or run. I understand alot of this information is vague and incomplete. but any help would be much appreciated. I don't want be confinded to programming only when the linux labs are open on campus.
Thanks in advance.
 
What is a jds file? I've never heard of those. Are you sure it isn't a JAR file?
 
I'm sorry i wasn't clear enough. They just call it a jds. Its not a file, it is a directory containtaining classes that we need to use in our programs, but do not need to create our selves.
 
You can compile on OS X the same way you do on Linux -- java and javac via the Terminal.

If you want to include a JAR file in XCode (or a JDS file, whatever that is) just drag and drop it into the same directory as your .java files on the left-hand side of the window. Don't forget your "extends" or "include" comments at the top of your .java files.
 
the jds file isn't a file, its a directory of classes. the classes of the abstract data structures we are to implament. The code i am trying to compile is in the same directory, but the problem is, it keeps saying it cannot find the files/resolve symbols.
 
Did you "extend" the files in your .java files you're trying to write? Unless you tell the compiler that they're there to use, it'll ignore them.

I'm under the assumption that what is in the JDS directory are classes that need to be extended, and, ultimately defined (or overloaded) in your code.
 
they're not to be extended. For example: there is a class called Stack.java and it implements a stack ADT. and it is used in the program i am working on, but it is also provided by my teacher in the jds folder. He told us to add a CLASSPATH envyroment variable pointing to the jds folder for linux machines, but i don't know where i could do that on a Mac.
 
OK. I think jds is a package. Is that what your tutor/lecturer says? if it is, you need to make sure that the jds thingy is in the same directory as your code.

On a side note, you might want to forget about using XCode and try out Netbeans or Eclipse instead. I've found XCode's Java support to be quite poor compared to these two products. Give them a try and they're free too.

With regards to CLASSPATH's, you really shouldn't mess with those. Honestly. It has the potential to mess up your other Java apps and is more of a hassle than a help. Instead, you should use the -classpath flag when compiling and running. Here's an example of how you would us the -classpath flag

javac -classpath .;/my/path/to/jds myclass.java
java -classpath .;/my/path/to/jds myclass

However, if you're still keen on mucking about with the CLASSPATH, you need to know that it only works if you're compiling stuff through the terminal. In order to set your class path, you need to edit the file called .profile in your home directory. If it isn't there, create it. In that file, just add the line

export CLASSPATH=/path/to/jds

And you're done. Hope that helped.
 
I haven't tried developing anything in Java in XCode, but there is a way to add search paths in XCode that the linker searches.

Open the Inspector from the File menu and select the Styles tab.

Find the Library Search Paths and edit that to include the path to the directory containing the classes you need.
 
Back
Top