Results 1 to 2 of 2
  1. #1
    Psycode is offline Member
    Join Date
    Dec 2013
    United States of America
    Rep Power

    Question How do I change the name of a program?

    When I run my .jar i would like the window that pops up in the little start bar thingy to have a different name other tahn my main classes name. Any idea on how to fix this?

  2. #2
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Tucson, AZ
    Rep Power

    Default Re: How do I change the name of a program?

    On Windows and Linux, it should be sufficient to set the title of your JFrame. On OSX, you have to resort to some trickery...

    This sets the app title on OSX. You have to do this before you create the UI.

    Java Code:
    System.setProperty("", APP_TITLE);
    Apple also came up with some crap called Apple Java Extensions that helps Java apps integrate with the window manager, which is all automatic on other platforms. You have to dynamically load it because it won't exist on other platforms and may not exist on all versions of OSX. Here's how I did it in one of my apps:

    Java Code:
    if (System.getProperty("").contains("OS X")) {
    	try {
    		Class<?> klass = Class.forName("com.chalcodes.weaponm.gui.AppleExtensions");
    		Constructor<?> ctor = klass.getConstructor(Gui.class);
    		Runnable ext = (Runnable) ctor.newInstance(this);;
    	} catch (Throwable t) {
    		log.error("error loading Apple extensions", t);
    The class I refer to in that snippet is here:

    To compile it on another system, you'll need a stub library that replicates the Apple Java Extensions API. The most complete one I found was missing a couple things, so I forked it here:
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. A program that give change
    By Nixter1997 in forum New To Java
    Replies: 4
    Last Post: 08-23-2012, 02:42 PM
  2. Critique my change return program
    By atac57 in forum New To Java
    Replies: 3
    Last Post: 07-15-2012, 02:25 AM
  3. Replies: 12
    Last Post: 04-20-2012, 05:43 PM
  4. I need a java program for change denominations
    By TheSweetHelloKitty in forum New To Java
    Replies: 6
    Last Post: 02-16-2011, 01:24 AM
  5. Change the color in my program
    By carl in forum New To Java
    Replies: 5
    Last Post: 04-03-2009, 12:20 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts