newbie: howto executable jar file

  • Thread starter Olivier Laurent
  • Start date
O

Olivier Laurent

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
 
T

Thomas Schodt

Olivier said:
... 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?
 
T

Thomas Weidenfeller

Olivier said:
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
 
A

Andrew Thompson

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).
 
O

Olivier Laurent

Thomas Weidenfeller said:
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
 
O

Olivier Laurent

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,043
Members
48,769
Latest member
Clifft

Latest Threads

Top