View Full Version : Problem running Java apps
iGor
May 10, 2003, 07:32 AM
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.
Wes
May 10, 2003, 08:58 AM
Hi, I used to play with the terminal, but now I just use Project Builder (Dev. Tools) or JJ Edit. JJ Edit is a VERY simple program for compiling and running. Give it a try.
http://homepage.mac.com/jmacmullin/
lmalave
May 10, 2003, 10:58 AM
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.
Catfish_Man
May 10, 2003, 11:29 AM
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.
iGor
May 10, 2003, 02:46 PM
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?
Wes
May 10, 2003, 03:26 PM
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.
iGor
May 10, 2003, 03:40 PM
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?
dflett
May 11, 2003, 06:59 AM
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?
iGor
May 13, 2003, 02:23 PM
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?
Wes
May 13, 2003, 03:02 PM
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?
iGor
May 13, 2003, 05:31 PM
That code looks incomplete, here are my test bits
import javax.swing.JOptionPane;
public class Test {
public static void main( String args[] )
{
JOptionPane.showMessageDialog( null, "Yay!");
System.exit( 0 );
}
}
Wes
May 14, 2003, 12:55 AM
Originally posted by iGor
That code looks incomplete, here are my test bits
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.
iGor
May 14, 2003, 08:04 AM
Doesnt work, unresolved symbol UIManager
Wes
May 14, 2003, 10:04 AM
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.*;).
iGor
May 14, 2003, 08:06 PM
Doh!
Thanks Wes
Wes
May 15, 2003, 12:54 AM
Glad I could help.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.