Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 1998-07-27
2
Medium Priority
?
199 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 200 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

Build and deliver software with DevOps

A digital transformation requires faster time to market, shorter software development lifecycles, and the ability to adapt rapidly to changing customer demands. DevOps provides the solution.

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
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 will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

670 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