Solved

Creating a package in the .jar form

Posted on 2009-04-05
3
208 Views
Last Modified: 2013-11-23
I would like to allow importing a few classes and package them in a single .jar file. How can I create such a package with the minimal number of steps?

Some of those classes use the names introduced in the "dependent" classes (used during the compilation). Do I need to include those "dependent classes" in the package to be imported?

When I compile a .java file using the classes packaged in a .jar, I attempted to use the statements
import <class_name>;
I receive an error saying that javac expects a dot ('.') in the imported name. However, it seems to reject the statements:
import <package name>.<class name>;
0
Comment
Question by:tatavolk
  • 2
3 Comments
 
LVL 92

Accepted Solution

by:
objects earned 200 total points
ID: 24074295
your import statement needs to specify the fully qualified class name

eg.

import java.io.InputStream;

you need to import any class directly used in your class

0
 
LVL 12

Assisted Solution

by:basav_com
basav_com earned 300 total points
ID: 24074559
0
 
LVL 12

Assisted Solution

by:basav_com
basav_com earned 300 total points
ID: 24074564
You can use fatjar if you want to include other dependent jars and package it into a single .jar
http://fjep.sourceforge.net/fjeptutorial.html
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

920 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

17 Experts available now in Live!

Get 1:1 Help Now