Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Need help understanding jar file construction to utilize custom classHelpful Member! 

motoslide (MIS) (OP)
29 Mar 11 13:13
Newbie alert:
I have a vendor-supplied integration utility written in Java. They supplied a couple of jar files and a sample class which uses those custom methods. I now need to create my own jar file of a modified version of their example, and use that in a "java aware" application.
How do I create my custom jar file? Specifically, is the name of the jar file important, and the directory structure therein?
Should my jar file incorporate the vendor-supplied jar files, or do I need to move all 3 of them together as needed.
To help illustrate:
The sample code is called "SigCaptureDemo.class". I created a jar file called "BarSign.jar", which contains that class file and a MANIFEST.MF file. If I add "BarSign.jar" to my classpath, what would my corresponding "import" statement be?

I'd like to see an example of creating a custom "Hello World" class which can be used by another application and pass it a variable for the second word. In other words, allow it to print "Hello Earth", or "Hello AnyVariable". I think that would provide me with the understanding to address my specific needs.

Thanks for any pointers. Sorry that was such a long question.

"Proof that there is intelligent life in Oregon.  Well, Life anyway."

Helpful Member!  Diancecht (Programmer)
30 Mar 11 3:05
I'm not sure about how to start to answer your question. About jar files, you can pack them as you want, I don't think there's a fixed rule. A jar is like a container, a zip file intended to ease the burden of deliver a bunch of .class files, so you can do a single jar file with vendor and your classes.

Not sure if I'm helping, maybe this tutorial helps.

Cheers,
Dian

motoslide (MIS) (OP)
30 Mar 11 20:06
Thanks for the link to that tutorial. I've scanned quite a bit of it, but I still need a "push".

In one of their examples, I've created 3 small classes called Server, Client, and Utility. I've create a jar file which includes a "Main-Class:" label in the manifest file which allows the "Server" to be launched directly from a command line.

Now, I want to "include" those classes for another test project. I've added the jar file to my classpath. I've added "package myclass" at the beginning of each source file (then re-compiled and re-created the myclass.jar file). On my new project, I have this as my first line:
import myclass.*;
I get a compile-time error:
package myclass does not exit

Where am I going astray?

"Proof that there is intelligent life in Oregon.  Well, Life anyway."

Diancecht (Programmer)
31 Mar 11 5:25
Packages and imports have nothing to do with jars.

I'd take a look at the use of packages here before going on further.

Cheers,
Dian

motoslide (MIS) (OP)
6 Apr 11 20:46
Thanks once again.
I've been beating my head and have made some progress. I have a custom class now which does what I need and I'm able to launch it from within my "java aware" application. The utility runs as a frame with just a few buttons to capture a graphic and save it to a disk file. The only part which is still failing is my inability to close down the process. The demo I downloaded had a "System.exit(0)" line, which isn't allowed because my calling application is also running in the JVM. I changed that to a "dispose()". That appears to work, but my CPU pegs at 100% and stays there until I kill the JVM. Is there a better way to discard the frame once it has accomplished my needs?

 

"Proof that there is intelligent life in Oregon.  Well, Life anyway."

Diancecht (Programmer)
7 Apr 11 2:42
A call to setVisible(false) is also adviceable, and be sure there are no references to the JFrame so the garbage collection can get rid of it.

Cheers,
Dian

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close