Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

JAR file not running

Posted on 2004-04-20
21
Medium Priority
?
1,572 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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