Re: Creating a .jar package file

From: Mike B (mrcics2000-news-nomail_at_nomail.yahoo.com)
Date: 09/30/04


Date: Wed, 29 Sep 2004 18:53:28 -0500

Andrew Thompson <SeeMySites@www.invalid> wrote:
> On Wed, 29 Sep 2004 15:56:33 -0500, Mike B wrote:
>
>> OK, now I'm really stuck and I can't get things clear in my mind.
>>
>> I've created an application Prob3PaneApp ..
>
> Java class names should be meaningful, rather than short.
>
> Problem3PaneApplication might be better, but for a final
> GUI, something closer to what it *does* is preferable..

I'm just following instructions ;). Besides, I doubt the application /does/
anything, it justs put a pane up and ask for some unrelated data and then
multipleis it by something. The idea here is to get used to calling methods
and to create a class.

>
>> ..in directory \fall2004\bcis\ this
>> application won't compile
>
> * Is this class required for the jar? Because..
>
>> ...because it needs to find a class Prob3Customer.

I wrote Prob3Customer. It is a class file, it compiles clean, I can't test
it until I can get the application to instantiate a class and call the
methods for the class...

>>
>> I've created a class Prob3Customer in directory
>> \fall2004\bcis\edu\mpb\Prob3 this compiles clean and creates a
>> .class file.
>>
>> I've run "jar cvf prob3.jar edu\mpb\prob3" this says it included
>> the class Prob3Customer in the .jar file.
>
> ..there is no point to this jar without the Prob3PaneApp,
> if that class is required.

Right, that is why I'm trying to get the .jar file somewhere so I can
compile (using javac) my application Prob3PaneApp.
>
> If it is a class with a ..
> public static void main(String[] args)
> ..method, you should be able to both compile and *run* it from
> the command line before jarring it.

In Prob3PaneApp, I have the ..

public static void main(String[] args)

in it I have

customer = new Prob3Customer

and then I call some setters and getters for customer

This won't compile without finding the class file for Prob3Customer

In Prob3Customer.java, I have

public class Prob3Customer

the constructor ...
   public Prob3Customer()

and then some set and get methods for variables in the class.

This compiles clean and creates the .class file that I'm hoping I can get
javac to pick up for compiling Prob3PaneApp....

>
>> Now I'm stuck.... where on earth do I have to put the .jar file ..
>
> No. Wind back and look into getting the app. running first.
> (but your intuition not to put in into the class path was
> correct, that is poor practice, generally)
>
> BTW - What's the book you are studying?
> (Title, author and ISBN)

Murach's beginning Java 2 by Andrea Steelman, ISBN 1-890774-12-x
must admit it was the first time I got my head around the object-oriented
thing when I read it in that book, it was as if a light switched on....

>
> One last thing.. your subject. "Creating a .jar package file"
> almost suggests you see jars and packages as the same. They
> are not. Packages represent the directories in which Java class
> files reside. Jars are collections of packaged and unpackaged
> classes, as well as any other resources you might want to
> put into the jar file, images and HTML help files, configuration
> files, as well as possibly a manifest to indicate the main class,
> and 'class signature' files.. A jar file is really a specialized(?)
> form of zip file.

Cool, I must admit I thought they were more or less the same thing. What is
the "include" statement looking for? A class or a .jar file? I know that I
code a "package" statement in the Prob3Customer class. Maybe I'll backtrack
to there and start again....

>
> Try renaming one from .jar to .zip and double click it
> to see what I mean.

-- 
Mike B 


Relevant Pages

  • Re: Creating a .jar package file
    ... Here is the compile of the Prob3Customer class file: ... ->location: class Prob3PaneApp ...
    (comp.lang.java.help)
  • COBOL copybook <-> Java bean mapper??
    ... A while back I wrote a dialog to take a COBOL ... copy book, compile it, and generate a Java class that could be used to map ... program and analysing the MAP and SYSADATA output. ...
    (bit.listserv.ibm-main)
  • Re: Jar file only works on my pc
    ... I use textPad 4 to compile and command line to make ... I open the jar file using 7zip and all of the class files are ... my other applets work fine. ... I think I have the $'s because of my actionListener inner classes. ...
    (comp.lang.java.programmer)
  • Re: Eclipse IDE Question
    ... and debug but can't figure out to compile a JAR file! ... Eclipse compiles Java files on ... What do you exactly mean by compiling a JAR file? ... Thanks Roland - I didn't know about the "Export" step. ...
    (comp.lang.java.programmer)
  • Re: Eclipse IDE Question
    ... When "Build Automatically" is selected, Eclipse compiles Java files on the fly, so your project is always in a "built"-state. ... You'll never have to compile or build a project yourself. ... What do you exactly mean by compiling a JAR file? ...
    (comp.lang.java.programmer)