Difference in program execution on Mac and on Windows
Author |
Message |
RichardP
|
Posted: Sat Jul 25, 2009 11:57 pm Post subject: 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
Description: |
|
![](http://compsci.ca/v3/pafiledb/images/icons/clip.gif) Download |
Filename: |
G2P5.java |
Filesize: |
14.84 KB |
Downloaded: |
240 Time(s) |
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
DemonWasp
|
Posted: Sun Jul 26, 2009 1:42 am Post subject: 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.
|
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
Posted: Sun Jul 26, 2009 12:36 pm Post subject: Re: Difference in program execution on Mac and on Windows |
|
|
RichardP @ Sat Jul 25, 2009 11:57 pm wrote: 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.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
![](images/spacer.gif) |
RichardP
|
Posted: Sun Jul 26, 2009 7:09 pm Post subject: Re: Difference in program execution on Mac and on Windows |
|
|
Tony @ Sun Jul 26, 2009 12:36 pm wrote: RichardP @ Sat Jul 25, 2009 11:57 pm wrote: 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]
|
|
|
|
|
![](images/spacer.gif) |
RichardP
|
Posted: Sun Jul 26, 2009 7:20 pm Post subject: Re: RE:Difference in program execution on Mac and on Windows |
|
|
DemonWasp @ Sun Jul 26, 2009 1:42 am wrote: 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...
|
|
|
|
|
![](images/spacer.gif) |
andrew.
|
|
|
|
![](images/spacer.gif) |
gianni
![](http://compsci.ca/v3/uploads/user_avatars/2828365714b5bd9cc211e8.png)
|
Posted: Sun Jul 26, 2009 11:56 pm Post subject: 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.
|
|
|
|
|
![](images/spacer.gif) |
[Gandalf]
![](http://compsci.ca/v3/uploads/user_avatars/189297994e4c716fec7f1.png)
|
Posted: Mon Jul 27, 2009 3:14 am Post subject: Re: Difference in program execution on Mac and on Windows |
|
|
RichardP @ 2009-07-26, 7:09 pm wrote: 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.
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
RichardP
|
Posted: Mon Jul 27, 2009 10:02 am Post subject: Re: RE:Difference in program execution on Mac and on Windows |
|
|
andrew. @ Sun Jul 26, 2009 10:45 pm wrote: Download Java 1.6 for Mac: 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)
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
|
|
|
|
|
![](images/spacer.gif) |
RichardP
|
Posted: Mon Jul 27, 2009 11:56 am Post subject: Re: Difference in program execution on Mac and on Windows |
|
|
RichardP @ Sat Jul 25, 2009 11:57 pm wrote: 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
~
|
|
|
|
|
![](images/spacer.gif) |
andrew.
|
Posted: Mon Jul 27, 2009 12:11 pm Post subject: Re: RE:Difference in program execution on Mac and on Windows |
|
|
RichardP @ Mon Jul 27, 2009 10:02 am wrote:
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 You want Java SE 6 because that's Java 6. J2SE is the original version which is 5.
RichardP wrote:
Bonjour,
OMG (I spend too much time around teenagers... ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) )
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.
|
|
|
|
|
![](images/spacer.gif) |
RichardP
|
Posted: Mon Jul 27, 2009 1:17 pm Post subject: Re: RE:Difference in program execution on Mac and on Windows |
|
|
andrew. @ Mon Jul 27, 2009 12:11 pm wrote: RichardP @ Mon Jul 27, 2009 10:02 am wrote:
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 You 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?
RichardP wrote:
Bonjour,
OMG (I spend too much time around teenagers... ![Wink Wink](http://compsci.ca/v3/images/smiles/icon_wink.gif) )
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!
|
|
|
|
|
![](images/spacer.gif) |
|
|