Maximum PC

It is currently Wed Sep 17, 2014 2:33 pm

All times are UTC - 8 hours

Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Java app distribution question
PostPosted: Wed Jun 23, 2010 2:57 pm 

Joined: Tue Feb 01, 2005 12:17 pm
Posts: 1479
If i write an app (not web page applet) in Java, when I want to distribute the App, do I just distribute the .CLASS files, or do I need to distribute the actual source-code .JAVA files as well?

 Post subject: Re: Java app distribution question
PostPosted: Sat Jun 26, 2010 7:35 pm 

Joined: Tue Dec 15, 2009 11:27 am
Posts: 47
Java application are typically distributed in .jar files, which are just zipped up class files with ".jar" extension. Distributing source code is of no use when it comes to running the app.

The simplest "manual" way to package your app is to go to the root directory where the class files are compiled and just zip it up with your favorite zip tool and change the ".zip" to ".jar". You'll also need to distribute a batch file or shell script that launches the app by calling something like:

java -cp <semicolon delimited list of jarfiles> <main class> [arguments...]

If your using Eclipse you can export your project as an executable jar file, which allows you to launch it using:

java -jar <jarfile> [arguments...]

 Post subject:
PostPosted: Mon Jul 05, 2010 3:08 pm 
Bitchin' Fast 3D Z8000*
Bitchin' Fast 3D Z8000*
User avatar

Joined: Tue Jun 29, 2004 11:32 pm
Posts: 2555
Location: Somewhere between compilation and linking
As TF_Titan mentioned, the standard paradigm for distributing an application in Java is using the Java Archive facilities (ie jars). While a jar and zip file are similiar, there is one important difference -- the manifest. Among other things, the manifest is used to indicate which class is the "main class" in a jar, so when you run "java -jar my.jar" it knows which of possibly several main methods to start.

The zip file thing is kind of gimicky. Instead, read the instructions for the jar command and practice creating a few jars manually, just so that you know how to do it. Then go to the website for your IDE and search for a tutorial on how they "export" or create a jar file. At this point, things should start making sense.

Another popular way for distributing Java apps is Java Web Start (JWS). If you need some kind of method for distributing your jars across a network, this is the way to go. Learn how to create jar files first though... it isn't a replacement for them. HTHs.

Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 8 hours

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group