newbie: howto executable jar file

Discussion in 'Java' started by Olivier Laurent, Mar 3, 2004.

  1. Hi there,

    I'm playing with Java for about a month now. My background is perl.

    I'm using "Head First Java" and "Developping games in Java" to learn
    this language. Both are fun to read and making 3D games helps me to be
    very excited :eek:)

    My editor is Jedit+Ant plug-in with Apache ant installed on a Linux
    distro (SUSE).

    I can compile/run my app through Jedit (ant-farm project: run...)
    without any problem. So the code in itself seems fine.

    Yesterday a friend of mine asked me to send him my project to test it
    on his computer.

    Well...I tried for the first time to make a Jar file. I build my
    project using Jedit and ant. I write a manifest with Main-Class:
    EventTest called manifest.txt . I copied manifes.txt to the root
    directory.

    The project has several subdirectories. All of them are present in the
    build subdirectory. These subdirectories contain crucial class to be
    imported.

    When I run jar
    (jar -cvmf manifest.txt test.jar *)

    It seems that it compresses all neccessary subdirectories

    But when I try

    java -jar test.jar EventTest

    I receive the following Error:

    Exception in thread "main" java.lang.NoClassDefFoundError:
    java/awt/DisplayMode
    at com.brackeen.javagamebook.test.GameCore.<clinit>(GameCore.java:17)

    Subdirectories have been compressed into test.jar . At least I can see
    traces in the process.


    What is missing?

    Thanks

    Olivier
     
    Olivier Laurent, Mar 3, 2004
    #1
    1. Advertising

  2. Olivier Laurent wrote:

    > ... when I try
    >
    > java -jar test.jar EventTest
    >
    > I receive the following Error:
    >
    > Exception in thread "main" java.lang.NoClassDefFoundError:
    > java/awt/DisplayMode
    > at com.brackeen.javagamebook.test.GameCore.<clinit>(GameCore.java:17)


    This class lives in ./lib/rt.jar in the JRE
    (in ./jre/lib/rt.jar in the SDK).

    Is there a complete JRE or SDK on the target machine?

    What does "java -version" say?
     
    Thomas Schodt, Mar 3, 2004
    #2
    1. Advertising

  3. Olivier Laurent wrote:
    > Exception in thread "main" java.lang.NoClassDefFoundError:
    > java/awt/DisplayMode
    > at com.brackeen.javagamebook.test.GameCore.<clinit>(GameCore.java:17)
    >


    DisplayMode was added to Java in 1.4. Check the installed Java version.

    /Thomas
     
    Thomas Weidenfeller, Mar 3, 2004
    #3
  4. On 3 Mar 2004 02:15:34 -0800, Olivier Laurent wrote:
    ....
    > Yesterday a friend of mine asked me to send him my project to test it
    > on his computer.
    >
    > Well...I tried for the first time to make a Jar file.

    .....
    > java -jar test.jar EventTest

    ....
    > Exception in thread "main" java.lang.NoClassDefFoundError:
    > java/awt/DisplayMode


    There is something I do not quite get
    here Olivier. Is the jar failing for
    the 'friend of yours' on his PC, or is
    it failing on _yours_?

    Both Thomas' seemed to think it was your
    freinds machine, but I read it different.
    Could you clarify?

    And to check which versions of Java are
    on each machine, you might check here..
    <http://www.physci.org/codes/jre.jsp>

    Just check each of the versions listed
    at the top unitl redirected (..1.5
    is a lie though - I must update the
    applet).

    --
    Andrew Thompson
    * http://www.PhySci.org/ Open-source software suite
    * http://www.PhySci.org/codes/ Web & IT Help
    * http://www.1point1C.org/ Science & Technology
     
    Andrew Thompson, Mar 3, 2004
    #4
  5. Thomas Weidenfeller <> wrote in message news:<c24gr6$cfd$>...
    > Olivier Laurent wrote:
    > > Exception in thread "main" java.lang.NoClassDefFoundError:
    > > java/awt/DisplayMode
    > > at com.brackeen.javagamebook.test.GameCore.<clinit>(GameCore.java:17)
    > >

    >
    > DisplayMode was added to Java in 1.4. Check the installed Java version.
    >
    > /Thomas


    You both were right. Jedit pointed to a freshly installed SDK (1.4.X)
    while JRE was an old-timer (1.3). All I needed to do is EXPORT
    JRE_HOME=/usr/.../j2sdk.1.4/jre

    Thanks both ;-), now i've got my first working jar!

    Olivier
     
    Olivier Laurent, Mar 3, 2004
    #5
  6. > And to check which versions of Java are
    > on each machine, you might check here..
    > <http://www.physci.org/codes/jre.jsp>



    Andrew,

    The problem was on a single machine, mine.

    I had two Virtual machines installed on my PC.

    JRE 1.3 and J2SDK 1.4

    Javac came from J2SDK 1.4 and java came from JRE 1.3.

    So jedit could compile my code because it uses j2SDK but my linux bash
    kept using the old JAVA virtual machine
    (JAVA_HOME=/usr/lib/java/jre1.3.X/...). and jar was of course from
    J2SDK and not from JRE. Thomas told me that the error was made by an
    old-timer (I was using 1.4 java new functions).

    When I was using java -jar, I was using java 1.3. My jar file works
    but was too advanced for java 1.3.

    The only thing I had to do was to change JAVA_HOME. (export
    JAVA_HOME=/usr/local/j2sdk1.4.1_06/...)

    and changes the symbolic link over java.... rm -f /usr/bin/java ->
    /usr/lib/java/jre1.3.2/bin/ ... ln -s
    /usr/local/j2sdk1.4.1_06/jre/bin/java /usr/bin/java

    Olivier
     
    Olivier Laurent, Mar 4, 2004
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Arnold Peters
    Replies:
    0
    Views:
    589
    Arnold Peters
    Jan 5, 2005
  2. muttley
    Replies:
    0
    Views:
    2,735
    muttley
    Oct 20, 2005
  3. cyberco
    Replies:
    4
    Views:
    3,782
    Roedy Green
    Feb 14, 2006
  4. Arnold Peters
    Replies:
    0
    Views:
    672
    Arnold Peters
    Jan 5, 2005
  5. Jason Cavett
    Replies:
    8
    Views:
    624
    Sanjay
    May 16, 2007
Loading...

Share This Page