Solved

Creating Packages and then adding them to a Zip File...

Posted on 1998-07-27
2
157 Views
Last Modified: 2010-03-30
I have a two part question.
I know how to create a package by using the "package" statement.
My question is can you keep .java code in its own file system(directory) and compile it so the resulting package is put into a common directory?  

I am trying to create packages and have them put into a common file system.  The only way i know how to do this is by putting the .java code into this common directory and compile it.

The reason for this is so i can zip all the classes and add them to one common class directory.

My second question is:  
Does anyone have an example of a makefile that will compile .java code then put it into a .zip file?

thanks in advance!!!!!!!!!!!!!
0
Comment
Question by:jefftk99
2 Comments
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
Comment Utility
I am not sure I fully understand the issue.

You compile java source with javac command which has -dir flag. You can use that flag to tell it where to position the .class files. The class file has to be in the directory structure matching its package name. If the package name is com.acme.mypackage than the class file should be in the com\acme\mypackage directory under some directory on the class path.

If you want to create a ZIP archive it is fine too. Make sure the directory path of your class file in the archive matches its package name. I use WinZip to create archives (I do not think this can be done from a make file). PkZip probably allows that. You can use JAR command to create an archive, but I found this command rather inflexible. The syntax is

jar -cvf jarfile_name classfile_names

You have to run JAR from the directory at the top of the package hierarchy (that is the one containing the com directory in my example). Let me know if I did not answer your question.
0
 

Author Comment

by:jefftk99
Comment Utility
Thank you.

0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
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…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

771 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

11 Experts available now in Live!

Get 1:1 Help Now