
-----------------------------------
RichardP
Sat Jul 25, 2009 11:57 pm

Difference in program execution on Mac and on Windows
-----------------------------------
Hi,
I was working on a program on my Mac and could not get the KeyListener to work as expected. In fact, it was a program from a book on Java (Programming Video Games for the Evil Genius).  I then tried the same code on a Windows running XP and it worked as expected. Any ideas why?  On my Mac, I am running 1.5.0_19 and compiled using NetBeans 6.7; on the PC, it's 1.6.0_10 using JCreator.  Here is the code I (tried to) run:
(from www.mhprofessional.com/authors/cinnamon and look for Section 2, game 5).

Thanks for your time,
Rick

-----------------------------------
DemonWasp
Sun Jul 26, 2009 1:42 am

RE:Difference in program execution on Mac and on Windows
-----------------------------------
Judging by the console output while running your game, this program is full of errors. Pressing "p" ends up generating null pointer exceptions in several threads before it finally says "yes, I typed 'p'" (which I assume to be the correct response). Typing 'x' worked, but typing 'z' caused an ArrayIndexOutOfBounds exception.

Couldn't tell you why it works differently on Windows versus Mac...I'm on Linux.

-----------------------------------
Tony
Sun Jul 26, 2009 12:36 pm

Re: Difference in program execution on Mac and on Windows
-----------------------------------
On my Mac, I am running 1.5.0_19 and compiled using NetBeans 6.7; on the PC, it's 1.6.0_10 using JCreator.
Well for starters you are using different languages (Java 5 vs. Java 6), with different compilers (NetBeans vs. JCreator), running on different JVMs. The OS might not even matter here.

-----------------------------------
RichardP
Sun Jul 26, 2009 7:09 pm

Re: Difference in program execution on Mac and on Windows
-----------------------------------
On my Mac, I am running 1.5.0_19 and compiled using NetBeans 6.7; on the PC, it's 1.6.0_10 using JCreator.
Well for starters you are using different languages (Java 5 vs. Java 6), with different compilers (NetBeans vs. JCreator), running on different JVMs. The OS might not even matter here.

Hi,
Thanks for this. Yes, the versions are completely different, but should that really matter? Are there really big differences between Javas 5 and 6?  Any idea where I can get some information on what the potential differences are?  The code does not seem that complicated or specialized, so I would assume there should be no big problems.  I have also compiled from the terminal window with the following results:

avac -Xlint G2P5.java 
G2P5.java:217: warning: [unchecked] unchecked call to add(E) as a member of the raw type java.util.ArrayList
        lines.add(new Line2D.Double(holder,end));
                 ^
G2P5.java:13: warning: [serial] serializable class G2P5 has no definition of serialVersionUID
public class G2P5 extends JFrame implements MouseListener, KeyListener
       ^
2 warnings


... and nothing from the terminal when I execute the code.

Yes, I am now turning towards these warnings to try to understand them.

Thanks again,
Rick[/u][/i]

-----------------------------------
RichardP
Sun Jul 26, 2009 7:20 pm

Re: RE:Difference in program execution on Mac and on Windows
-----------------------------------
Judging by the console output while running your game, this program is full of errors. Pressing "p" ends up generating null pointer exceptions in several threads before it finally says "yes, I typed 'p'" (which I assume to be the correct response). Typing 'x' worked, but typing 'z' caused an ArrayIndexOutOfBounds exception.

Couldn't tell you why it works differently on Windows versus Mac...I'm on Linux.

Thanks.  Interesting results.  When I use a terminal window on my Mac, I get nothing, regardless of the key I type. I also found the Console (new to this Mac thingy) and ditto, no output.  Weird...

-----------------------------------
andrew.
Sun Jul 26, 2009 10:45 pm

RE:Difference in program execution on Mac and on Windows
-----------------------------------
Download Java 1.6 for Mac: [url=http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105update1.html]http://www.apple.com/downloads/macosx/apple/application_updates/javaformacosx105update1.html

Change the default JVM version with Java Preferences. (Press Command + Space to open Spotlight and search for "Java Preferences" or if it's not there, open Applications/Utilities/Java Preferences.app)

-----------------------------------
gianni
Sun Jul 26, 2009 11:56 pm

RE:Difference in program execution on Mac and on Windows
-----------------------------------
Console.app is not a shell, simply put, it's a log viewer. It also shows the system log by default, handy when debugging broken apps.

-----------------------------------
[Gandalf]
Mon Jul 27, 2009 3:14 am

Re: Difference in program execution on Mac and on Windows
-----------------------------------
Are there really big differences between Javas 5 and 6?
Yes, at least from what I've noticed Java 5 -> Java 6 breaks (or fixes, I guess?) certain things.  The code runs, however either no user input is received or the program doesn't update for whatever reason.  I don't remember the exact issue, so I can't be more specific.

-----------------------------------
RichardP
Mon Jul 27, 2009 10:02 am

Re: RE:Difference in program execution on Mac and on Windows
-----------------------------------
Download Java 1.6 for Mac: 

Thanks for the info, Andrew.  I am new to the Mac and I just bought it a month ago.  I ran the Java Preferences app and I guess I already have:
J2Se - 32 bits - 1.5.0_19
Java SE 6 - 64 bits - 1.6.0_13
J2SE 5.0 - 64 bits -  1.5.0_19
J2SE 1.4.2 - 32 bits - 1.4.2_21

Any idea where I can get some information on what this means - i.e. what's the difference between J2SE and Java SE 6?
Thanks,

Rick

-----------------------------------
RichardP
Mon Jul 27, 2009 11:56 am

Re: Difference in program execution on Mac and on Windows
-----------------------------------
Hi,
I was working on a program on my Mac and could not get the KeyListener to work as expected. In fact, it was a program from a book on Java (Programming Video Games for the Evil Genius).  I then tried the same code on a Windows running XP and it worked as expected. Any ideas why?  On my Mac, I am running 1.5.0_19 and compiled using NetBeans 6.7; on the PC, it's 1.6.0_10 using JCreator.  Here is the code I (tried to) run:
(from www.mhprofessional.com/authors/cinnamon and look for Section 2, game 5).

Thanks for your time,
Rick

Bonjour,
   
OMG (I spend too much time around teenagers... ;)    )  

I went back over the code and tried previous versions (originally, in my haste, I went to the final version, G2P5). I compiled and ran G2P1, G2P2, G2P3 and, much to my surprise, everything worked fine.  

While looking for differences (in order to post the insulting snippet), I removed a JOptionPane.showMessageDialog (contains game instructions) from the constructor and everything works!!

Any idea why???  And it did work on my PC...  
Thanks to all those who took the time to reply - I am sure more questions will come up as I delve into Java!
 
Have a nice day,
Rick
~

-----------------------------------
andrew.
Mon Jul 27, 2009 12:11 pm

Re: RE:Difference in program execution on Mac and on Windows
-----------------------------------

Thanks for the info, Andrew.  I am new to the Mac and I just bought it a month ago.  I ran the Java Preferences app and I guess I already have:
J2Se - 32 bits - 1.5.0_19
Java SE 6 - 64 bits - 1.6.0_13
J2SE 5.0 - 64 bits -  1.5.0_19
J2SE 1.4.2 - 32 bits - 1.4.2_21

Any idea where I can get some information on what this means - i.e. what's the difference between J2SE and Java SE 6?
Thanks,

RickYou want Java SE 6 because that's Java 6. J2SE is the original version which is 5.


Bonjour,
   
OMG (I spend too much time around teenagers... ;)    )  

I went back over the code and tried previous versions (originally, in my haste, I went to the final version, G2P5). I compiled and ran G2P1, G2P2, G2P3 and, much to my surprise, everything worked fine.  

While looking for differences (in order to post the insulting snippet), I removed a JOptionPane.showMessageDialog (contains game instructions) from the constructor and everything works!!

Any idea why???  And it did work on my PC...  
Thanks to all those who took the time to reply - I am sure more questions will come up as I delve into Java!
 
Have a nice day,
Rick
~

Weird, you must be doing something wrong because JOptionPane.showMessageDialog works on Mac.

-----------------------------------
RichardP
Mon Jul 27, 2009 1:17 pm

Re: RE:Difference in program execution on Mac and on Windows
-----------------------------------

Thanks for the info, Andrew.  I am new to the Mac and I just bought it a month ago.  I ran the Java Preferences app and I guess I already have:
J2Se - 32 bits - 1.5.0_19
Java SE 6 - 64 bits - 1.6.0_13
J2SE 5.0 - 64 bits -  1.5.0_19
J2SE 1.4.2 - 32 bits - 1.4.2_21

Any idea where I can get some information on what this means - i.e. what's the difference between J2SE and Java SE 6?
Thanks,

RickYou want Java SE 6 because that's Java 6. J2SE is the original version which is 5.

Okay, that's logical... So, when in a terminal window, I should see 1.6.0_13 when I issue the java -version command, if I have everything setup properly, right?


Bonjour,
   
OMG (I spend too much time around teenagers... ;)    )  

I went back over the code and tried previous versions (originally, in my haste, I went to the final version, G2P5). I compiled and ran G2P1, G2P2, G2P3 and, much to my surprise, everything worked fine.  

While looking for differences (in order to post the insulting snippet), I removed a JOptionPane.showMessageDialog (contains game instructions) from the constructor and everything works!!

Any idea why???  And it did work on my PC...  
Thanks to all those who took the time to reply - I am sure more questions will come up as I delve into Java!
 
Have a nice day,
Rick
~

Weird, you must be doing something wrong because JOptionPane.showMessageDialog works on Mac.

Oh yeah, it works, just not from the constructor!
