Solved

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

Posted on 1998-07-27
2
181 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which non-HTML GUI front end to use with Java? 3 67
Chrome and Firefox Java 5 88
Bot application - advice 3 81
How to log java errors in tomcat 8 39
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 …
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn about if statements in Java and their use The if statement: The condition required to create an if statement: Variations of if statements: An example using if statements:
Suggested Courses

738 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