LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 06-07-2004, 12:27 AM   #1
balanagireddy
Member
 
Registered: Sep 2003
Location: India
Distribution: redhat linux 9.0
Posts: 46

Rep: Reputation: 15
how to run a jar file in redhat9.0


I have no idea about java. I have this .jar file(that i downloaded) that I need to run.
when i use gij -jar I get a lot of errors.
so how shoud I run this jar file ?
By the way I use Redhat 9.0
 
Old 06-07-2004, 01:43 AM   #2
adz
Senior Member
 
Registered: Jun 2003
Location: Sydney
Distribution: Debian, FreeBSD
Posts: 1,713

Rep: Reputation: 53
You need to get the java runtime environment and then run it through that. Usually, you'd do a (path/to/)java <filename>.jar.

Last edited by adz; 06-07-2004 at 04:04 AM.
 
Old 06-07-2004, 01:58 AM   #3
balanagireddy
Member
 
Registered: Sep 2003
Location: India
Distribution: redhat linux 9.0
Posts: 46

Original Poster
Rep: Reputation: 15
Quote:
Originally posted by adz
You need to get the java runtime environment and then run it throught that. Usually, you'd do a (path/to/)java <filename.jar.
Sorry i couldnt follow you.
The method specified in the Readme file was java -cp "$DIR/yab.jar:$DIR/sample.jar" sample.Main 0 - - - - - - $*
So can you please elaborateon what u said
 
Old 06-07-2004, 02:51 AM   #4
motub
Senior Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Gentoo (main); SuSE 9.3 (fallback)
Posts: 1,607

Rep: Reputation: 46
If the path to the Java binary is in your $PATH$ statement, you can just use "java blah blah blah" to run a Java program. However, the java binary is often not in your $PATH$, because Java installs to an out-of-the- way location (no matter which of the several versions you might install) that is not in the default $PATH$ statement, and Java weirdly does not generally add itself to the PATH (which just stinks, frankly. Either it should install to a standard location, or it should add itself to the PATH).

So if you just type "java anything" the program will not run because the system does not know where Java is (that's the function of the $PATH$ statement, to tell the system where it should look for executable programs by default).

So you can either add Java to your $PATH$ statement and use the command as written (without a path to Java being included in the command), or you can use the command as edited to read /path/to/java -cp "$DIR/yab.jar:$DIR/sample.jar.

Hope this helps.
 
Old 06-07-2004, 02:51 AM   #5
dtournas
Member
 
Registered: Aug 2003
Location: Charlotte, North Carolina
Distribution: Red Hat (and look-alike), SUSE (when drunk), Slackware (when mad)
Posts: 148

Rep: Reputation: 15
Hi,

I am not sure that the .jar extension is for java files. I think it is for compressed archives. Try to open the file with mc (midnight commander - just type mc). Maybe the file you are looking is inside the archive.

Let me know!
 
Old 06-07-2004, 02:56 AM   #6
motub
Senior Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Gentoo (main); SuSE 9.3 (fallback)
Posts: 1,607

Rep: Reputation: 46
Jar files are compressed Java archives. They can be run with Java (as in the case of Mozilla, Firefox, Thunderbird and other Mozilla-based browsers and email clients), or the contents can be viewed in an archive manager.

But .jar archives are usually not meant to be extracted; they are meant to be run with Java.
 
Old 06-07-2004, 03:04 AM   #7
balanagireddy
Member
 
Registered: Sep 2003
Location: India
Distribution: redhat linux 9.0
Posts: 46

Original Poster
Rep: Reputation: 15
Well actually the path for the java exists since normal .java files run properly.
But somehow the .jar files are creating a problem. Hence i dont think the path specification is a problem. But its got to do something with jar files specifically
Hope you can help me more
 
Old 06-07-2004, 03:14 AM   #8
motub
Senior Member
 
Registered: Sep 2003
Location: The Netherlands
Distribution: Gentoo (main); SuSE 9.3 (fallback)
Posts: 1,607

Rep: Reputation: 46
What exactly are you trying to do? And what is the application in question?

From man java
Quote:
java(1) java(1)



NAME
java - Java interpreter

SYNOPSIS
java [ options ] class [ argument ... ]

java [ options ] -jar file.jar
[ argument ... ]

PARAMETERS
Options may be in any order. For a discussion of parameters which apply to a specific option, see OPTIONS below.

options Command-line options. See OPTIONS below.

class Name of the class to be invoked.

file.jar Name of the jar file to be invoked. Used only with the -jar option.

DESCRIPTION
The java utility launches a Java application. It does this by starting a Java runtime environment, loading a specified class, and invoking that class's main method. The method must have the following signature:

public static void main(String args[])

The method must be declared public and static, it must not return any value, and it must accept a String array as a parameter. By default, the first non-option argument is the name of the class to be invoked. A fully-qualified class name should be used. If the -jar option is specified, the first non-option argument is the name of a JAR archive containing class and resource files for the application, with the startup class indicated by the Main-Class manifest header.

The Java runtime searches for the startup class, and other classes used, in three sets of locations: the bootstrap class path, the installed extensions, and the user class path.

Non-option arguments after the class name or JAR file name are passed to the main function.

OPTIONS
The launcher has a set of standard options that are supported on the current runtime environment and will be supported in future releases. However, options below that are described as having been replaced by another one are obsolete and may be removed in a future release. An additional set of non-standard options are specific to the current virtual machine implementation and are subject to change in the future. Non-standard options begin with -X.

Standard Options
-client Selects the Java HotSpot Client VM. This is the default.

-server Selects the Java HotSpot Server VM.

-classpath classpath

-cp classpath Specifies a list of directories, JAR archives, and ZIP archives to search for class files. Class path entries are separated by colons (:). Specifying -classpath or -cp overrides any setting of the CLASSPATH environment variable.

Used with java, the -classpath or -cp options only specify the class path for user classes. Used with -classpath or -cp specify the class path for both user classes and bootstrap classes.

If -classpath and -cp are not used and CLASSPATH is not set, the user class path consists of the current directory (.).
What this indicates is that the sample command is incomplete; the -cp switch needs to have a CLASSPATH specified, which it does ($DIR/yab.jar:$DIR/sample.jar are telling the command where to look for the CLASSPATH)-- but there is no actual command to follow (-jar file.jar or <argument>). So all the "command" you have listed does is look up some CLASSNAMES, which is not going to be visible to you.

So again, what are you trying to do, and what program are you trying to run, whose readme contained this command?

Last edited by motub; 06-07-2004 at 03:17 AM.
 
Old 06-07-2004, 04:24 AM   #9
adz
Senior Member
 
Registered: Jun 2003
Location: Sydney
Distribution: Debian, FreeBSD
Posts: 1,713

Rep: Reputation: 53
Well what exactly happens when you run the command given to you in the README file? Cut and paste both the command and the output here.
 
Old 06-07-2004, 07:10 AM   #10
balanagireddy
Member
 
Registered: Sep 2003
Location: India
Distribution: redhat linux 9.0
Posts: 46

Original Poster
Rep: Reputation: 15
Well I have a very large code consisting of some seven independent programs which should be run concurrently. These programs are in java.
Of these two programs are jar files which are the troublemakers

well the below one example would be clearer i hope

#!/bin/bash
function canonicalname {
program="$0"

while [ -h "$program" ] ; do
cd `dirname "$program"`
program=`basename "$program"`
program=`ls -l "$program"`
program=${program##*-> }
done

cd `dirname "$program"`
echo $PWD/`basename $program`
}

DIR=`dirname \`canonicalname "$0"\``
java -Xmx128m -jar $DIR/../program/viewer/*.jar $*

And i execute as # ./2viewer.sh
what i get is :


Warning: -Xmx128m not understood. Ignoring.
Warning: -jar not understood. Ignoring.
Exception in thread "main" java.lang.NoClassDefFoundError: .home.rama.Project.boot....program.viewer.viewer-0.12.jar
at 0x40268e17: java.lang.Throwable.Throwable(java.lang.String) (/usr/lib/./libgcj.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/lib/./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, boolean) (/usr/lib/./libgcj.so.3)
at 0x08048910: ?? (??:0)
at 0x42015574: __libc_start_main (/lib/tls/libc.so.6)
at 0x080486c1: ?? (??:0)

all the paths given are quite correct

So does this simplify my question ?
 
Old 06-07-2004, 07:12 AM   #11
balanagireddy
Member
 
Registered: Sep 2003
Location: India
Distribution: redhat linux 9.0
Posts: 46

Original Poster
Rep: Reputation: 15
The bash file which i pasted is 2viewer.sh
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to run a java jar file. sabliny Programming 7 11-05-2005 02:59 PM
howto run a java.jar file in FC2-3 mickeyboa Fedora 1 02-11-2005 02:01 PM
Fedora Core 1 Associating .jar files with java -jar command pymehta Fedora 0 01-13-2005 06:26 AM
Cannot not run executable jar file after set content type for download antony_csf Programming 1 12-08-2004 01:22 AM
Using Tomcat to run a .jar file davee Linux - Software 1 08-15-2003 06:47 AM


All times are GMT -5. The time now is 06:52 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration