java game for mac

B

bob

I made a java slot machine game for mac, but i don't know how to
distribute it or package it.

Do I need to create a batch file or shell script that says something
like:

java -classpath .:jogl.jar SlotMachine

If I just run the class, it gives me an error.
 
L

Lew

I made a java [sic] slot machine game for mac, but i [sic] don't know how to
distribute it or package it.

Do I need to create a batch file or shell script that says something
like:

java -classpath .:jogl.jar SlotMachine

If I just run the class, it gives me an error.

You need to study classpaths generally. All libraries on which the
program depends must be available.

The proper way to distribute applications is in a JAR file, putting it
in turn in a ZIP file along with its dependencies (such as the
"jogl.jar" dependency that you show). You then unpack the ZIP into
the target machine at a deployment directory of your choice (e.g.,
"deploymentDir/", perhaps under your home directory).

Read the online docs about the "jar" command:
http://download.oracle.com/javase/6/docs/technotes/guides/jar/index.html

Also, the tutorials get into some depth about deployment and JARs:
http://download.oracle.com/javase/tutorial/deployment/index.html
http://download.oracle.com/javase/tutorial/deployment/jar/index.html

Put the dependency JARs in the same directory as the application JAR,
or in a subdirectory thereof.

For example,

deploymentDir/
||
=== slotgame.jar
||
=== lib/
||
=== jogl.jar
etc.

Set up the dependencies (jogl.jar) in the "Class-Path:" section of the
JAR manifest.

Then you can use your OS to associate the JAR with the "java -jar"
command, much as you associate ".odt" with OpenOffice.

You can also create a shell file to run "java -jar slotgame.jar".

Bear in mind that with the "-jar" option, the "java" command ignores
the CLASSPATH envar and the "-classpath" ("-cp") options.

Study the links!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top