• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Slightly OT: Command line Java tool with EOF?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Slightly OT: Command line Java tool with EOF?


  • Subject: Re: Slightly OT: Command line Java tool with EOF?
  • From: "John Huss" <email@hidden>
  • Date: Wed, 10 Sep 2008 09:09:48 -0500

There are a couple of ways to do this that Wonder offers - ERXMainRunner and something else I don't remember.

But anyway, are you starting from the same working directory in both cases?  That can affect the process.

John

On Wed, Sep 10, 2008 at 6:55 AM, Will Scheidegger <email@hidden> wrote:
Partially answering my own questions:

- Yes, things really depend heavily on that NSBundle stuff.
- Setting up the NSBundles programatically is a pain but feasible (see below)
=> I'm sure there is a better way to do things, but I do not have enough know-how to figure it out.

This has worked for me:

       // this automatically adds the bundles to the list of framework bundles
       NSBundle javaEOAccessBundle = NSBundle._bundleWithPathShouldCreateIsJar("/System/Library/Frameworks/JavaEOAccess.framework", true, false);
       NSBundle javaEOControlBundle = NSBundle._bundleWithPathShouldCreateIsJar("/System/Library/Frameworks/JavaEOControl.framework", true, false);
       NSBundle javaFoundationBundle = NSBundle._bundleWithPathShouldCreateIsJar("/System/Library/Frameworks/JavaFoundation.framework", true, false);
       NSBundle javaJDBCAdaptorBundle = NSBundle._bundleWithPathShouldCreateIsJar("/System/Library/Frameworks/JavaJDBCAdaptor.framework", true, false);


       EOModelGroup mg = new EOModelGroup();
       EOModelGroup.setDefaultGroup(mg);
       URL url = "">        mg.addModelWithPathURL(url);
       EOModel coachModel = mg.modelNamed("coach");

       EOEditingContext ec = new EOEditingContext();
       EOFetchSpecification f = new EOFetchSpecification("Coach", null, null);
       System.out.println("" + ec.objectsWithFetchSpecification(f).count() + " coaches found!");

If somebody ever figures out the hidden secrets of how to set up NSBundle please let me know.

Regards,
will



On 10.09.2008, at 09:15, 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 >"

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

regards
will
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 = "">     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

_______________________________________________
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

References: 
 >Slightly OT: Command line Java tool with EOF? (From: Will Scheidegger <email@hidden>)
 >Re: Slightly OT: Command line Java tool with EOF? (From: Lachlan Deck <email@hidden>)
 >Re: Slightly OT: Command line Java tool with EOF? (From: Will Scheidegger <email@hidden>)
 >Re: Slightly OT: Command line Java tool with EOF? (From: Will Scheidegger <email@hidden>)

  • Prev by Date: Re: Slightly OT: Command line Java tool with EOF?
  • Next by Date: PK generation?!?
  • Previous by thread: Re: Slightly OT: Command line Java tool with EOF?
  • Next by thread: Re: Slightly OT: Command line Java tool with EOF?
  • Index(es):
    • Date
    • Thread