Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JAR file not running

Posted on 2004-04-20
21
Medium Priority
?
1,575 Views
Last Modified: 2013-11-23
Hello all, I have a jar file that i created via IDE (netbeans), the Jar file runs fine when i execute through IDE. When i try and run through command line with:

java -jar MySQLHourlyUpdater.jar

I get many errors:

Warning: -jar not understood. Ignoring.
Exception in thread "main" java.lang.NoClassDefFoundError: MySQLHourlyUpdater.ja
r
   at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./li
bgcj.so.3)
   at 0x4025bc8e: java.lang.Error.Error(java.lang.String) (/usr/lib/./libgcj.so.
3)
   at 0x4025d6b6: java.lang.LinkageError.LinkageError(java.lang.String) (/usr/li
b/./libgcj.so.3)
   at 0x4025eb36: java.lang.NoClassDefFoundError.NoClassDefFoundError(java.lang.
String) (/usr/lib/./libgcj.so.3)
   at 0x402ad075: gnu.gcj.runtime.FirstThread.run() (/usr/lib/./libgcj.so.3)
   at 0x4024fc4c: _Jv_ThreadRun(java.lang.Thread) (/usr/lib/./libgcj.so.3)
   at 0x4021c8ac: _Jv_RunMain(java.lang.Class, byte const, int, byte const, bool
ean) (/usr/lib/./libgcj.so.3)
   at 0x08048910: ?? (??:0)
   at 0x42015574: __libc_start_main (/lib/tls/libc.so.6)
   at 0x080486c1: ?? (??:0)

I am running linux RH9. This jar relies on both MySQL driver, and oracle driver. I have a feeling that the drivers are being mounted through ide, but not outside of IDE...please help thanks
0
Comment
Question by:91mustang
  • 8
  • 8
  • 5
21 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 10868220
what version of java are you running it with?

java -version

will tell you...  it doesn't seem to recognise the "-jar", which leads me to believe it's 1.2 or something... :-/

Then, when that is sorted, you are right, you will need to add the other driver jars to the classpath for this app to run (which will require you to run it normally via:

java -cp MySQLHourlyUpdater.jar:mysql.jar:oracle.jar MainClass

(replacing mysql.jar and oracle.jar with the real jar names, and MainClass with the main class in your jar)

Putting this inside a shell script (run.sh) will make things easier, as you won't have to remember what you did between attempts :-)
0
 
LVL 4

Author Comment

by:91mustang
ID: 10868248
Hello Tim I have version 1.3. I thought that supports jar files? Am i wrong? any ideas

thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868301
What output do you get from the command Tim mentioned?

java -version
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 35

Expert Comment

by:TimYates
ID: 10868307
try the "java -cp" route...

it's odd that you get:  "Warning: -jar not understood. Ignoring."

As -jar was introduced in java version 1.2

You say it works inside Netbeans?  Is it using the same jdk?
0
 
LVL 4

Author Comment

by:91mustang
ID: 10868311
>> What output do you get from the command Tim mentioned?

java version "1.3.1"
jdkgcj 0.2.3 (http://www.arklinux.org/projects/jdkgcj)
gcj (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
0
 
LVL 4

Author Comment

by:91mustang
ID: 10868318
>>You say it works inside Netbeans?  Is it using the same jdk?

Ah thats it,  The netbeans install has version 1.4.2... the command line is using 1.3 (must have cam with os install), any ideas on how to force it to use 1.4.2
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868329
Hmm. I'm not an expert on *nix Java set ups. What we're looking at is not Sun of course so it's conceivable that -jar is not supported
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10868365
Yeah, I'd stick to 1.4.2 (sun)  -- thouygh I'm probably gonna get harranged by the GCJ/OSS lot for suggesting that ;-)

netbeans should have put 1.4.2 somewhere in /usr/bin/java (ish)

do the following:

cd /
find . -name javac

that should show you where javac is...  then set your $PATH variable to point to 1.4.2 version, not the 1.3 one
0
 
LVL 86

Assisted Solution

by:CEHJ
CEHJ earned 80 total points
ID: 10868375
>>any ideas on how to force it to use 1.4.2

Point it at the 1.4 runtime. i.e. you need to put in the full path to 1.4 java executable
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868388
It's actually the runtime that was the original problem, not javac, but similar principles hold
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10868406
> it's actually the runtime that was the original problem, not javac, but similar principles hold

yeah, but if you search for "java" you will get all manner of things including folders you or other people may have named java ;-)

Searching for javac cuts down your options... and won't show you any jre's you may have installed...
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868453
Yes. The way to stop that of course is

find / -type f -name java
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10868462
> find / -type f -name java

show-off ;)

hee hee
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868541
Just for future reference ..;-)
0
 
LVL 4

Author Comment

by:91mustang
ID: 10868651
Ok guys, excuse my ignorance (i am useless with linux)....

I have found javac in 2 directories:

/usr/bin/javac
/home/mike/j2sdk_nb/j2sdk1.4.2/bin/javac

The first one seems to be a text file (i can read it, it is the non sun one)
The other one is the sun one, but it is in binary format.

How do i go about changing the path to point to the new one?

thanks
0
 
LVL 35

Accepted Solution

by:
TimYates earned 120 total points
ID: 10868671
export PATH=/home/mike/j2sdk_nb/j2sdk1.4.2/bin:$PATH

(I think)
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10868676
then type

java -version

and see what it says
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868691
If you're working at the command line, i'd be inclined to leave the path as it is as it might affect other software adversely and write yourself a little shell script for use with Java, or just set the path per Java session in that terminal
0
 
LVL 4

Author Comment

by:91mustang
ID: 10868737
Thank you very much guys, the help is very much appreciated as always!!!
0
 
LVL 35

Expert Comment

by:TimYates
ID: 10868746
Good luck with it :-)

Tim
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 10868778
8-)

Yep. Another way of looking at it of course is that if something like

String[] s = "a,b,c".split(",");

doesn't compile in NetBeans, then you have outdated Java in NB that should be updated to work with 1.4.2 unless you've a good reason not to.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question