Solved

JAR file not running

Posted on 2004-04-20
21
1,555 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
Comment Utility
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
Comment Utility
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
Comment Utility
What output do you get from the command Tim mentioned?

java -version
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
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
Comment Utility
>> 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
Comment Utility
>>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
Comment Utility
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
Comment Utility
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
Comment Utility
>>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
Comment Utility
It's actually the runtime that was the original problem, not javac, but similar principles hold
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 35

Expert Comment

by:TimYates
Comment Utility
> 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
Comment Utility
Yes. The way to stop that of course is

find / -type f -name java
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
> find / -type f -name java

show-off ;)

hee hee
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
Just for future reference ..;-)
0
 
LVL 4

Author Comment

by:91mustang
Comment Utility
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
Comment Utility
export PATH=/home/mike/j2sdk_nb/j2sdk1.4.2/bin:$PATH

(I think)
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
then type

java -version

and see what it says
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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
Comment Utility
Thank you very much guys, the help is very much appreciated as always!!!
0
 
LVL 35

Expert Comment

by:TimYates
Comment Utility
Good luck with it :-)

Tim
0
 
LVL 86

Expert Comment

by:CEHJ
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
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 …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

771 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now