Solved

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

Posted on 1998-07-27
2
190 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 5

Accepted Solution

by:
msmolyak earned 50 total points
ID: 1228528
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
ID: 1228529
Thank you.

0

Featured Post

Get HTML5 Certified

Want to be a web developer? You'll need to know HTML. Prepare for HTML5 certification by enrolling in July's Course of the Month! It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

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

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
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…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

628 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