Same jar file does not run on different platforms

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • muquaddim
    New Member
    • Jun 2007
    • 11

    Same jar file does not run on different platforms

    Hi,
    First of all I am not a java programmer. what I am doing is just trying to port a precompiled game to other machine.
    I have a java game project. the final output or the game is "game.jar". I compiled this in fedora with netbeans (5.5.1) ide. It was running well in fedora.
    But The problem arises when I try to run that same jar file from windows with same command. I used same jdk in both linux and windows.
    when I run it from fedora
    # java -jar game.jar
    works ok
    but in windows
    C:\src\java\Che rryGame\>java -jar game.jar
    Exception in thread "AWT-EventQueue-0" java.lang.Numbe rFormatExceptio n: For input string: ""
    at java.lang.Numbe rFormatExceptio n.forInputStrin g(NumberFormatE xception.java:4 8)
    at java.lang.Integ er.parseInt(Int eger.java:468)
    at java.lang.Integ er.parseInt(Int eger.java:497)
    at cherrygame.glob al.readConfigFo rStickProtectio n(global.java:2 060)
    at cherrygame.nbCh erryGame.<init> (nbCherryGame.j ava:243)
    at netbeansapplica tion.nbApplicat ion.<init>(nbAp plication.java: 46)
    at netbeansapplica tion.nbApplicat ion$14.run(nbAp plication.java: 453)
    at java.awt.event. InvocationEvent .dispatch(Invoc ationEvent.java :209)
    at java.awt.EventQ ueue.dispatchEv ent(EventQueue. java:597)
    at java.awt.EventD ispatchThread.p umpOneEventForF ilters(EventDis patchThread.jav a:273)
    at java.awt.EventD ispatchThread.p umpEventsForFil ter(EventDispat chThread.java:1 83)
    at java.awt.EventD ispatchThread.p umpEventsForHie rarchy(EventDis patchThread.jav a:173)
    at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:168)
    at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:160)
    at java.awt.EventD ispatchThread.r un(EventDispatc hThread.java:12 1)

    I use the same directory structure in both linux and windows. in fact I use the same jar file all the time. the source tree is accessible in both linux and windows.

    Can anyone tell me how to make it run successfully?
    I am stuck.
  • sateesht
    New Member
    • Apr 2007
    • 41

    #2
    Originally posted by muquaddim
    Hi,
    First of all I am not a java programmer. what I am doing is just trying to port a precompiled game to other machine.
    I have a java game project. the final output or the game is "game.jar". I compiled this in fedora with netbeans (5.5.1) ide. It was running well in fedora.
    But The problem arises when I try to run that same jar file from windows with same command. I used same jdk in both linux and windows.
    when I run it from fedora
    # java -jar game.jar
    works ok
    but in windows
    C:\src\java\Che rryGame\>java -jar game.jar
    Exception in thread "AWT-EventQueue-0" java.lang.Numbe rFormatExceptio n: For input string: ""
    at java.lang.Numbe rFormatExceptio n.forInputStrin g(NumberFormatE xception.java:4 8)
    at java.lang.Integ er.parseInt(Int eger.java:468)
    at java.lang.Integ er.parseInt(Int eger.java:497)
    at cherrygame.glob al.readConfigFo rStickProtectio n(global.java:2 060)
    at cherrygame.nbCh erryGame.<init> (nbCherryGame.j ava:243)
    at netbeansapplica tion.nbApplicat ion.<init>(nbAp plication.java: 46)
    at netbeansapplica tion.nbApplicat ion$14.run(nbAp plication.java: 453)
    at java.awt.event. InvocationEvent .dispatch(Invoc ationEvent.java :209)
    at java.awt.EventQ ueue.dispatchEv ent(EventQueue. java:597)
    at java.awt.EventD ispatchThread.p umpOneEventForF ilters(EventDis patchThread.jav a:273)
    at java.awt.EventD ispatchThread.p umpEventsForFil ter(EventDispat chThread.java:1 83)
    at java.awt.EventD ispatchThread.p umpEventsForHie rarchy(EventDis patchThread.jav a:173)
    at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:168)
    at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:160)
    at java.awt.EventD ispatchThread.r un(EventDispatc hThread.java:12 1)

    I use the same directory structure in both linux and windows. in fact I use the same jar file all the time. the source tree is accessible in both linux and windows.

    Can anyone tell me how to make it run successfully?
    I am stuck.


    Hi,

    Java is a Platform independent Language, moreover Jar contains only class files, and Java itself says that "Write Once Run Any where " so it has to be executed, and moreover you have written this source code and compiled it using the Tool , please cross check whether there are any tool specific xml files are there for configuration, if that is the case you are unable to execute the code.

    Cheers,
    Sateesh.

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by muquaddim
      Exception in thread "AWT-EventQueue-0" java.lang.Numbe rFormatExceptio n: For input string: ""
      at java.lang.Numbe rFormatExceptio n.forInputStrin g(NumberFormatE xception.java:4 8)
      at java.lang.Integ er.parseInt(Int eger.java:468)
      at java.lang.Integ er.parseInt(Int eger.java:497)
      at cherrygame.glob al.readConfigFo rStickProtectio n(global.java:2 060)
      at cherrygame.nbCh erryGame.<init> (nbCherryGame.j ava:243)
      at netbeansapplica tion.nbApplicat ion.<init>(nbAp plication.java: 46)
      at netbeansapplica tion.nbApplicat ion$14.run(nbAp plication.java: 453)
      at java.awt.event. InvocationEvent .dispatch(Invoc ationEvent.java :209)
      at java.awt.EventQ ueue.dispatchEv ent(EventQueue. java:597)
      at java.awt.EventD ispatchThread.p umpOneEventForF ilters(EventDis patchThread.jav a:273)
      at java.awt.EventD ispatchThread.p umpEventsForFil ter(EventDispat chThread.java:1 83)
      at java.awt.EventD ispatchThread.p umpEventsForHie rarchy(EventDis patchThread.jav a:173)
      at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:168)
      at java.awt.EventD ispatchThread.p umpEvents(Event DispatchThread. java:160)
      at java.awt.EventD ispatchThread.r un(EventDispatc hThread.java:12 1)
      From what I see in that stack trace the game is trying to read some configuration
      data. Are you sure you packed the correct config data with the .jar? Maybe the
      game is reading from other config data when run in fedora.

      kind regards,

      Jos

      Comment

      • muquaddim
        New Member
        • Jun 2007
        • 11

        #4
        Originally posted by sateesht
        Hi,

        Java is a Platform independent Language, moreover Jar contains only class files, and Java itself says that "Write Once Run Any where " so it has to be executed, and moreover you have written this source code and compiled it using the Tool , please cross check whether there are any tool specific xml files are there for configuration, if that is the case you are unable to execute the code.

        Cheers,
        Sateesh.
        actually I compiled it with netbeans 5.5.1
        netbeans uses ant as backend as far I found in forums. then I compiled it by ant.
        #ant -buildfile build.xml
        my build file is here, I omitted the comments

        Code:
        <?xml version="1.0" encoding="UTF-8"?>
        <project name="NetBeansApplication" default="default" basedir=".">
            <description>Builds, tests, and runs the project NetBeansApplication.</description>
            <import file="nbproject/build-impl.xml"/>
            <target name="-post-jar">
                <jar update="true" destfile="${dist.jar}">
                    <zipfileset src="${libs.swing-layout.classpath}"/>
                    <zipfileset src="${libs.addMoney.classpath}"/>
                    <zipfileset src="${libs.NormalWindow.classpath}"/>
                </jar>
            </target>
        </project>

        Comment

        Working...