Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Old Project New XCode: The Main Class Can Not Be Found



Xi Golom wrote:

>The main class, Procession, was declared in a package.
>
>package procession;
>...
>public class Procession
>{
>...
>
>My Info.plist MainClass entry had been:
>
><key>MainClass</key>
><string>Procession</string>
>
>I needed to change it to:
>
><key>MainClass</key>
><string>procession.Procession</string>
>
>Then the app runs.

It's very strange that it ever worked, as given.

I've mistyped plenty of main-class names, and never had one work if it was
missing its full package name.  I've also moved a main class to another
package and forgotten to change the Info.plist (or manifest), and the
resulting app never works until I fix the package name in Info.plist (or
the manifest).

Are you sure your new app isn't the victim of an error created in the
project by Xcode's conversion from older to newer project-file format?  I'm
not saying I've observed such an error occurring, just that we really need
to see both the "before" and "after" projects or apps before concluding
what the cause is.

What Xcode version is your old project-file?  What new Xcode version?

Can you go back to your old Java app's working app-bundle, i.e. the one
produced by the old Xcode, display the contents of the bundle, open its
Info.plist file, and post what its MainClass is?  Please do this on the
actual old working app-bundle, not the Xcode project or any of its source
files.  It's important to see the actual case that works, in order to work
back to the case that fails (the new Info.plist).

I'm also curious what Procession class is in the old working app's jar-file:
  cd your/OldApp.app/Contents/Resources/Java
  jar tf yourApp.jar | grep Procession

If there's more than one jar, repeat for each jar.

I mention the class-file in the jar because sometimes I've written
main-classes that have no package name, but do have the app-name I want
displayed in the menubar.  This class is nothing but a relay to the real
main-class in a package, but it causes the menubar to display without a
package-name.

For example, say my real main class is:
  package procession;
  public class Procession
  {  public static void main(String[] args) { ... }  }

If a CFBundleName is not defined in Info.plist, the java launcher stub will
put "procession.Procession" as the name of the application menu.  To
eliminate that, here's the "relay" main class:
  // no package
  public class Procession
  {
      public static void main(String[] args)
      {  procession.Procession.main( args );  }
  }

I then define MainClass in Info.plist to be "Procession", and not
"procession.Procession".  The application menu-name is then automatically
"Procession".

I use this trick more often in double-clickable jars, but I have plenty of
those that eventually get turned into an app-bundle, so still have the
relay-main-class in them.

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.