Re: Slightly OT: Command line Java tool with EOF?
Re: Slightly OT: Command line Java tool with EOF?
- Subject: Re: Slightly OT: Command line Java tool with EOF?
- From: Chuck Hill <email@hidden>
- Date: Wed, 10 Sep 2008 12:01:24 -0700
On Sep 10, 2008, at 12:15 AM, Will Scheidegger wrote:
I'm tempted to say "nothing" although of course there must be a
difference:
NetBeans:
/System/Library/Frameworks/JavaEOAccess.framework/Resources/Java/
javaeoaccess.jar
/System/Library/Frameworks/JavaFoundation.framework/Resources/Java/
javafoundation.jar
/System/Library/Frameworks/JavaEOControl.framework/Resources/Java/
javaeocontrol.jar
/Library/Java/Extensions/frontbasejdbc.jar
/System/Library/Frameworks/JavaJDBCAdaptor.framework/Resources/Java/
javajdbcadaptor.jar
CLI:
java -jar EOFTest.jar -cp /System/Library/Frameworks/
JavaEOAccess.framework/Resources/Java/javaeoaccess.jar:/System/
Library/Frameworks/JavaFoundation.framework/Resources/Java/
javafoundation.jar:/System/Library/Frameworks/
JavaEOControl.framework/Resources/Java/javaeocontrol.jar:/Library/
Java/Extensions/frontbasejdbc.jar:/System/Library/Frameworks/
JavaJDBCAdaptor.framework/Resources/Java/javajdbcadaptor.jar
But still:
NSBundle.mainBundle() on NetBeans =
"<com.webobjects.foundation.NSBundle name:'JavaFoundation'
bundlePath:'/System/Library/Frameworks/JavaFoundation.framework'
packages
:'(com.webobjects.foundation,com.webobjects.foundation.xml )' 215
classes >"
That is wrong. NSBundle can default to JavaFoundation when it can't
find the actual main bundle.
NSBundle.mainBundle() on CLI: null
I guess the questions are:
- can I get EOF to run without the NSBundle stuff
- or can I setup an NSBundle programmatically
I think you are running into path problems. NSBundle expects things
to be in specific paths. I am not sure how it handles this with jar
frameworks.
I suspect that if you made a directory structure like an app
EOFTest.woa/
Contents/
Resources/
Java/
EOFTest.jar
Then
cd EOFTest.woa
java -jar Contents/Resources/Java/EOFTest.jar -cp ....
That is would work.
Chuck
On 10.09.2008, at 08:56, Lachlan Deck wrote:
On 10/09/2008, at 4:48 PM, Will Scheidegger wrote:
I'm trying to access database data with EOF in a command line Java
app. These few lines of code work perfectly as long as I run them
in NetBeans but fail miserably when I try to run them on the CLI:
EOModelGroup mg = new EOModelGroup();
EOModelGroup.setDefaultGroup(mg);
URL url = this.getClass().getResource("/eoftest/
coach.eomodeld");
mg.addModelWithPathURL(url);
EOEditingContext ec = new EOEditingContext();
EOFetchSpecification f = new EOFetchSpecification("Coach",
null, null);
System.out.println("" +
ec.objectsWithFetchSpecification(f).count() + " coaches found!");
The reason for this - as far as I can tell - is, that when running
it from NetBeans, the app as a main bundle and framework bundles,
but it does not when I run it on the CLI (NSBundle.mainBundle() =
0, NSBundle.frameworkBundles() = empty). Now, I don't know how
NetBeans gets these bundles and that's not the issue. I would like
to know however how I can use EOF properly outside a wo app with
frameworks etc. Has anyone done this? Could you give me some
pointers?
What's different about the classpath?
with regards,
--
Lachlan Deck
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
--
Chuck Hill Senior Consultant / VP Development
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden