File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Mac OS and the fly likes Can't compile Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Mac OS
Bookmark "Can Watch "Can New topic
Author

Can't compile

Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
I have two class files, main.java and CreateUser.java which are both in the same directory, in the same xCode project. When I try to compile, main.java will work (Or pass; I don't know), but on Create user it says it can't import any of the frameworks.
What is going on?



jiju ka
Ranch Hand

Joined: Oct 12, 2004
Posts: 306

it says it can't import any of the frameworks

What is the error message exactly as it is displayed?
Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
Looking back at my post, Framework was a bad word to use there, Package would be more approprate. I'm fairly new to Java, so I'm totally clueless.

CreateUser.java:8: package com.webobjects.foundation does not exist
CreateUser.java:9: package com.webobjects.appserver does not exist
CreateUser.java:10: package com.webobjects.eocontrol does not exist
CreateUser.java:11: package com.webobjects.eoaccess does not exist
CreateUser.java:13: cannot resolve symbol symbol : class WOComponent
CreateUser.java:15: cannot resolve symbol symbol : class WOContext

edit: I understand enough to know that the last two errors are caused by the error described in the first 4
[ December 02, 2005: Message edited by: Matt McKay ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Hi Matt,

It looks like you need to specify a classpath to tell Java where to find these packages.

I'm not familiar with using xCode, so I don't know what functionality it might have for specifying classpaths in your projects. (You might try searching xCode's Help for "classpath". Also, since this is xCode, you might have better luck on the Mac OS forum.)

You could try simply using the classpath option (-cp) when compiling:
javac -cp whereMyPackagesAre MyClass.java

If you decide to set your classpath on a system level, then here's a nice GUI for doing this on Mac...

http://www.rubicode.com/Software/RCEnvironment/

Without a GUI, you should be able to use the Unix procedures described here...

http://faq.javaranch.com/view?HowToSetTheClasspath
[ December 02, 2005: Message edited by: marc weber ]

"We're kind of on the level of crossword puzzle writers... And no one ever goes to them and gives them an award." ~Joe Strummer
sscce.org
Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
I think my (xCode's) classpath is correct, but I went ahead and set it to where my frameworks should be. The result didn't change any.

What I don't understand is, I have two .java files, both are identical except their names, and the classes contained within. One compiles fine, the other throws errors. Huh?
Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
I've been stuck on this stupid problem for a week, and I'm no closer to having it working.

I believe my classpath is correct. One of my .java files in xCode compiles fine, but the other (identical import;s) .java file tells me it can't import because the files don't exist.

In a unrelated note, there are so few resources on the web for webobjects I want to rip my hair out. Apple's documentation sucks so badly I can't believe it.
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
I'm not sure if this has been addressed, but are the two .java files in the same directory?
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Originally posted by Keith Lynn:
I'm not sure if this has been addressed, but are the two .java files in the same directory?

Yes, in the first post, Matt indicated that the files are in the same directory and in the same xCode project. I've been searching the Mac OS forum for xCode tips, but there's not much there.

Matt: Have you tried compiling these files outside of xCode (just from Terminal)? It would be nice if we could verify that the files themselves are okay.
Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
Yes, the two .java files are in the same directory

edit: Ooops, I had this composed for a while and just hit submit, Ill get edit this with more info when I am done composing it
[ December 09, 2005: Message edited by: Matt McKay ]
Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
Sorry it took so long to reply.

If I try to compile main.java with javac I get errors about not finding the packages. xCode must pass the classpath as an arg to javac.
I'm looking into what xCode is setting the path to.


edit: It appears that the path "/System/Library/Frameworks/" contains the packages. I'll play around with javac and see what happens
[ December 12, 2005: Message edited by: Matt McKay ]
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

Matt,

This thread has been lingering in the beginner forum without much attention. It looks to me like the issue is realted to xCode, and since that's specific to Mac, I'm going to move this to the Mac forum in hopes of getting the attention of someone who knows xCode...
Matt McKay
Greenhorn

Joined: Dec 02, 2005
Posts: 7
Well I posted my question to a WO listserv and found my answer.
xCode, by default, adds the new .java files to the wrong build target.
To other xCode users: Add it to ApplicationServer, not the project name.
marc weber
Sheriff

Joined: Aug 31, 2004
Posts: 11343

I'm glad you got an answer, and thanks for posting it here!
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Can't compile
 
Similar Threads
generics doubt from nikos
Constructor not found error
SCJP Sun Certified Programmer for Java 6 Study Guide by Kathy Sierra & Bert Bates - Page 622
classes with private constructors can not be subclassed?
constructor