Solved

JAR file not running

Posted on 2004-04-20
21
1,558 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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 20 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 30 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
stackato and cloud 4 85
split string containing \r\n in Java 46 44
Android development question 2 37
going to wrong jsp page 2 21
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…

772 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