Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1585
  • Last Modified:

JAR file not running

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
91mustang
Asked:
91mustang
  • 8
  • 8
  • 5
2 Solutions
 
TimYatesCommented:
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
 
91mustangAuthor Commented:
Hello Tim I have version 1.3. I thought that supports jar files? Am i wrong? any ideas

thanks
0
 
CEHJCommented:
What output do you get from the command Tim mentioned?

java -version
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
TimYatesCommented:
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
 
91mustangAuthor Commented:
>> 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
 
91mustangAuthor Commented:
>>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
 
CEHJCommented:
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
 
TimYatesCommented:
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
 
CEHJCommented:
>>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
 
CEHJCommented:
It's actually the runtime that was the original problem, not javac, but similar principles hold
0
 
TimYatesCommented:
> 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
 
CEHJCommented:
Yes. The way to stop that of course is

find / -type f -name java
0
 
TimYatesCommented:
> find / -type f -name java

show-off ;)

hee hee
0
 
CEHJCommented:
Just for future reference ..;-)
0
 
91mustangAuthor Commented:
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
 
TimYatesCommented:
export PATH=/home/mike/j2sdk_nb/j2sdk1.4.2/bin:$PATH

(I think)
0
 
TimYatesCommented:
then type

java -version

and see what it says
0
 
CEHJCommented:
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
 
91mustangAuthor Commented:
Thank you very much guys, the help is very much appreciated as always!!!
0
 
TimYatesCommented:
Good luck with it :-)

Tim
0
 
CEHJCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 8
  • 8
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now