Solved

To Excecute an application from jar file

Posted on 2002-06-20
6
177 Views
Last Modified: 2013-11-23
I have a jar file (xyz.jar) with

a1.class
a2.class
a3.class
a4.class
in which a1.class is a main class having
public static void main(String[] args)

in my manifest file i have included
Main-Class: a1.class

Now the problem is how to execute this application from the jar file directly.
This jar file is in c:\abc directory
0
Comment
Question by:umaiyer
  • 3
  • 3
6 Comments
 
LVL 9

Expert Comment

by:Venci75
ID: 7095356
try
java -jar c:\abc\JarName.jar
0
 

Author Comment

by:umaiyer
ID: 7095379
i tried with the same command

I am getting this error:

Exception in thread "main" java.util.zip.ZipException: The system cannot find the file specified
        at java.util.zip.ZipFile.open(Native Method)
        at java.util.zip.ZipFile.<init>(ZipFile.java:112)
        at java.util.jar.JarFile.<init>(JarFile.java:117)
        at java.util.jar.JarFile.<init>(JarFile.java:55)

Can u just let me know what's the problem

Thanks in advance.
0
 
LVL 9

Expert Comment

by:Venci75
ID: 7095388
aha - the main class should be specified as a class name - not as a file name, that contain this class:
Main-Class: a1

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:umaiyer
ID: 7095594
if this jar file(jarname.jar) is dependend on another jar file (comm.jar),do i have to include that jar file name in the manifest file of jarname.jar. if so how can i do this
0
 
LVL 9

Accepted Solution

by:
Venci75 earned 100 total points
ID: 7095628
yes - you need to add it to your manifest file:

Class-Path: comm.jar
0
 

Author Comment

by:umaiyer
ID: 7098434
i have included all the jar files that are required by the application which is in jarname.jar

in the Class-Path: x1.jar x2.jar etc.......

this application also uses one xml file which is outside the jar file.This application loads the contents of the xml file.
do i have to include this xml file in the manifest file. if so how to include this resource.

the problem i am facing is.......

i have jar file & xml file in
c:\abc directory
if i go to c:\abc>java -jar jarname.jar
my application displays the contents xml file

if i give the command in this fashion
c:\>java -jar "c:\abc\jarname.jar"
my application does not displays the details of xml file

how to come across this problem. is there a way to come out of this
Thanks in advance

0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

For customizing the look of your lightweight component and making it look lucid like it was made of glass. Or: how to make your component more Apple-ish ;) This tip assumes your component to be of rectangular shape and completely opaque. (COD…
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
The viewer will learn how to implement Singleton Design Pattern in Java.

746 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

12 Experts available now in Live!

Get 1:1 Help Now