Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

crhardnett

macrumors newbie
Original poster
Feb 19, 2004
2
0
Atlanta, GA (EST)
Hello,

I am using Xcode to do some java development. I have some JAR files that I need to add to the classpath. I tried changing the project target to add the JAR files. However, this does not seem to update the classpath.

The detailed build output shows:

...stuff deleted...
classpath="/Users/hardnett/Research/Executive Asst/JudgeApp/build/JudgeApp.build/JudgeApp.build/JavaClasses$frameworkjars:"`/usr/bin/javaconfig DefaultClasspath`
...stuff deleted...

As you can the new classpath is developed from the projects framework jars adn the default classpath. The additional class path found in the Info.plist is not part of the classpath.

I would like to know if anyone has fixed/workaround this?

If not, does anyone know where this script exist that performs the compilation and what utility is used to read the Info.plist

Thanks,

Charles
 
Same problem accessing .class files

I have the same 'problem' accessing .class files rather than .jar files

how do I tell xcode to find them for compile and run time env's in Java

at the moment I am developing in pure java (tools)
 
A solution

Hi,

I did some poking around and developed a solution. I will also send a bug report to Apple about this, and see what happens. There may be something that is undocumented or something that I am completely missing.

In either case, the solution I have come up with is to check for/create a ~/Library/Java directory. Of course, the ~ is your home directory. This directory was not on my machine so I created it. It turns out that this directory is in the DefaultClasspath for java. This can be confirmed by the following at the prompt:

% javaconfig DefaultClasspath

Or you can look in the plist file /System/Library/Java/JavaConfig.plist for the same information.

In Either case, you can unpack your jar files into the ~/Library/Java directory:

% cd ~/Library/Java
% jar xf <jar-file>

This will of course use more disk space because the compression is lost, but it works. Now your new jar files will be part of the default path. Of course you could also use symbolic links to accomplish the same thing.

So until I learn of a better way to do this, I am using this method and it works great. Now if I could figure out how to make the Indexing feature index these added classes, then I'd be real happy.

I hope this helps.

Charles
 
XCode (Java) Classpath problems continue

Dear all,

A previous post said that XCode defaults to finding .class files (and .jars also?) in paths returned with:

javaconfig DefaultClasspath

I am currently using XCode 1.1 and it would appear that these other paths are only be used by javac (the compiling arm) and not the java runtime. I have created a package and saved it to /Library/Java. The build/compile process finds this OK, but when I run the project the java.lang.NoClassDefFoundError error is returned.

I can still run the command-line version but it of course uses CLASSPATH. I set my CLASSPATH to include `javaconfig DefaultClasspath`. If I use javac to compile and then change the CLASSPATH to be something that doesn't include /Library/Java, the same java.lang.NoClassDefFoundError error is returned (thus why I'm saying that the runtime doesn't use the DefaultClasspaths).

I will upgrade to XCode 1.2 to see if the issue is fixed in that version, however I have read the release notes and it doesn't mention anything about this (mind you any fix could have come in a dot release). If this doesn't fix the problem I will submit a bug report through the means mentioned in the release notes.

If anyone has any input to this situation I'd appreciate the discussion.

Cheers,

Brooke :(
 
OK, found it!

I had to subscribe to the http://lists.apple.com xcode-users mailing list to ask the question. I did, received a reply and here is my reply that has the answer.

From: novorivus
Subject: Re: Java dev in XCode & CLASSPATH
Date: 18 July 2004 22:31:17 GMT+10:00
To: dewing
Cc: xcode-users

Hi Dave,

Thanks for your reply.

I have to say that I don't understand why XCode has to be so different,
though I found the solution from your reply (thankyou). An entry from
my blog reads:

In XCode I chose the target application from the Target section and
double clicked it. This brought up a configuration dialog. I went down
to "Info.plist entries/Simple View/Pure Java Specific". In there I
added $(LOCAL_LIBRARY_DIR)/Java into the CLASSPATH field and now the
Java runtime finds the packages I specified.

So I'm quite ecstatic that I've got it working. But will I have to do
this manual confiiguration for each project I start? In XCode, why
doesn't java respect the same (classpath) mechanism that javac does?.
This still doesn't make sense to me.

I guess the differences is perspectives. XCode must be designed from
the perspective of building self-contained applications, where-as how I
work in what I do is to write systems on the same server. I'm sure
Eclipse or other IDE's don't work in this way (but yet to truly find
out).

Thankyou,

Brooke

Note that my classes are in /Library/Java.

For complete information, David replied:

This too is intentional (though not always convenient). It allows you to build against a .jar file containing only interfaces, and then run against the .jar file that contains the entire implementation. This allows you to be sure that you don't use any private APIs that are part of an implementation, since you'd get build-time errors. That said, it's also very common to build and run against the .jar files, and we don't make this easy enough.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.