Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > newbie: howto executable jar file

Reply
Thread Tools

newbie: howto executable jar file

 
 
Olivier Laurent
Guest
Posts: n/a
 
      03-03-2004
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 )

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>(G ameCore.java:17)

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


What is missing?

Thanks

Olivier
 
Reply With Quote
 
 
 
 
Thomas Schodt
Guest
Posts: n/a
 
      03-03-2004
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>(G ameCore.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?
 
Reply With Quote
 
 
 
 
Thomas Weidenfeller
Guest
Posts: n/a
 
      03-03-2004
Olivier Laurent wrote:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> java/awt/DisplayMode
> at com.brackeen.javagamebook.test.GameCore.<clinit>(G ameCore.java:17)
>


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

/Thomas

 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      03-03-2004
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
 
Reply With Quote
 
Olivier Laurent
Guest
Posts: n/a
 
      03-03-2004
Thomas Weidenfeller <(E-Mail Removed)> wrote in message news:<c24gr6$cfd$(E-Mail Removed)>. ..
> Olivier Laurent wrote:
> > Exception in thread "main" java.lang.NoClassDefFoundError:
> > java/awt/DisplayMode
> > at com.brackeen.javagamebook.test.GameCore.<clinit>(G ameCore.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
 
Reply With Quote
 
Olivier Laurent
Guest
Posts: n/a
 
      03-04-2004
> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running an Executable Before Executable JAR Jason Cavett Java 8 05-16-2007 07:14 PM
java -cp a.jar -jar b.jar => Works on Windows, not on Debian cyberco Java 4 02-14-2006 06:27 AM
jaas.jar, jta.jar jdbc-stdext.jar missing from jdk1.5 RPM muttley Java 0 10-20-2005 02:40 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters Java 0 01-05-2005 10:59 PM
Differences of xercesImpl.jar, xercesImpl-J.jar, dom3-xercesImpl.jar ? Arnold Peters XML 0 01-05-2005 10:59 PM



Advertisments