Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

iGor

macrumors newbie
Original poster
May 9, 2003
7
0
I am new to Macs and am trying to run 1.4.1 apps from the terminal.

javac myapp.java

java myapp

It uses java from 1.4.1 and the little java icon opens in the dock but nothing else happens and when I right click on the icon it offers force quit. The app is a simply JOptionPane Hello World so it shouldnt take long. println Hello World works fine. My applets work great in the browser.

Any help would be appreciated.
 
Hmm...weird. I guess it found the class, otherwise it would have given you a "class not found" error. Sounds like it might be a swing-related issue.

Just to make sure, maybe try running a simpler class that just does a:

System.out.println("Hello world!");

And see what happens with that, that'll help you isolate the problem.
 
Re: Problem running Java apps

Originally posted by iGor
I am new to Macs and am trying to run 1.4.1 apps from the terminal.

javac myapp.java

java myapp

It uses java from 1.4.1 and the little java icon opens in the dock but nothing else happens and when I right click on the icon it offers force quit. The app is a simply JOptionPane Hello World so it shouldnt take long. println Hello World works fine. My applets work great in the browser.

Any help would be appreciated.

Is it an applet? I believe they have to run using some sort of applet runner program (usually a browser, as you said). If not, try googling for how to force it back to 1.3.1 and see if that helps.
 
Is it an applet?

No. My applets work fine in Safari.

Just to make sure, maybe try running a simpler class that just does a:

I already tried that and it works fine. You may be right about a swing problem but I dont see why I would have one.

My system is not tweaked, everythings vanilla from Apple. I *shouldnt* be having any problems :mad:

Wes, I do not want to revert back to 1.3 and switching to jj edit or project builder is not a proper solution.

Hmmm, another thing, a simple C Hello World app fails to compile as well. What the heck?
 
Originally posted by iGor
No. My applets work fine in Safari.



Wes, I do not want to switch to jj edit or project builder is not a proper solution.

JJ edit is just a front end GUI and uses the usual Mac OS X compiler. So if you tried my solution I think you might isolate your problem.
 
JJ edit is just a front end GUI and uses the usual Mac OS X compiler. So if you tried my solution I think you might isolate your problem.

I got 1.4.1 from Apple. Isnt this the usual/default for OSX?
 
To get a definitive answer, you will need to post the code (or a link to it) so us seasoned Java developers can take a look. Are you setting the size of the JWindow/JFrame?
 
It works now.

Same exact code.

I reinstalled X. Was going to anyways because Elements complained about UFS on my main partition.

One question though, how do I get the java look rather than the aqua?
 
Originally posted by iGor
It works now.

Same exact code.

I reinstalled X. Was going to anyways because Elements complained about UFS on my main partition.

One question though, how do I get the java look rather than the aqua?

public static void main(String[] args) {
try {
UIManager.setLookAndFeel(
UIManager.getCrossPlatformLookAndFeelClassName());
} catch (Exception e) { }

...//Create and show the GUI...

that help?
 
That code looks incomplete, here are my test bits


Code:
import javax.swing.JOptionPane;

public class Test {

    public static void main( String args[] )
    {
		    	JOptionPane.showMessageDialog( null, "Yay!");
	
	System.exit( 0 );
    }
}
 
Originally posted by iGor
That code looks incomplete, here are my test bits


Code:
import javax.swing.JOptionPane;

public class Test {

    public static void main( String args[] )
    {
		    	JOptionPane.showMessageDialog( null, "Yay!");
	
	System.exit( 0 );
    }
}

The code I posted was the code that gives swing the java look, not a complete app.
 
Originally posted by iGor
Doesnt work, unresolved symbol UIManager

Maybe is has something to do with that fact that you didn't load all of swing (import javax.swing.*;).
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.