Solved

Create a Jar file

Posted on 2007-03-20
6
186 Views
Last Modified: 2013-11-23
I have just 2 classes in a package

com.user.Hello1
com.user.Hello2

I want to ship them as a jar file, so that user can put them in his class path and use the class he needs. In each class I am also using a logger (log4j.jar). So I have a log4j.properties file as well which contians the destination directory where the logger should write.

Please tell me
1. How to create a jar of these classes.
2. How should the log4j.properties be shipped, should it be inside the jar or send seperately. If it is inside the jar then user will not be able to chage the destination directory, so creating a properties files will become useless.

Both the classes have a main method, so they'll be run seperately

0
Comment
Question by:ruchie
  • 3
  • 2
6 Comments
 
LVL 12

Accepted Solution

by:
Gibu George earned 150 total points
ID: 18762037
jar -cvf myjar.jar com *.properties, will create the jar file
0
 
LVL 12

Expert Comment

by:Gibu George
ID: 18762041
the log4j.properties can be shipped separately and needs to be in the class path
0
 
LVL 19

Assisted Solution

by:Kuldeepchaturvedi
Kuldeepchaturvedi earned 50 total points
ID: 18762051
use command
jar cvf mypackage.jar -C yourdirectory/.

on the command line... the jar.exe is present in the bin folder of your JDK install directory
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 18762055
oops sorry Gibu.. I guess while I was typing you posted your comments..
0
 
LVL 12

Expert Comment

by:Gibu George
ID: 18762077
:-)
0
 
LVL 30

Expert Comment

by:Mayank S
ID: 18774803
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Windows 10 IE Certificate Issue 10 51
iterator/ListIterator approach 17 39
Eclipse Java import and method not resolved 4 50
American Express @Work site and Java 4 30
An old method to applying the Singleton pattern in your Java code is to check if a static instance, defined in the same class that needs to be instantiated once and only once, is null and then create a new instance; otherwise, the pre-existing insta…
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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 …
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

828 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