Creating Archive Files in Eclipse with images.

S

Sanny

I have created an applet that has 20-30 images.

I want all of them to be put in one archive file. and I just display
the archive file in applet.

<applet code="HelloWorld.class" width="800" height="600"
archive="Helloworld.jar">

I found somewhere I can omit the .class prefix.

<applet code="HelloWorld" width="800" height="600"
archive="Helloworld.jar">

My images are on the same directory as the classfile.

How to create a .jar file in eclipse?

I tried to Export in Eclipse It gives two options.

1. Export -> Create Archive file.
2. Export -> Java -> Create Jar

Do they both are the same things?

Can I create .zip instead of .jar will that work with applets?

<applet code="HelloWorld" width="800" height="600"
archive="Helloworld.jip">

I found Eclipse gives no option to add images to the .jar file. Can I
use winzip to create a zip/ jar file?

How to include all images in the .jar file.

Incase I use .zip and compression will it work on all browsers.

I find it asks for Manifest File? What is this? What information can I
give to Manifest file? What will happen If I do not give manifest
file. As my applet already know the class to start with?

Once I create the .jar file Do I have to add the .class files to the
server? Will .jar provide everything the applet needs?

Bye
Sanny
 
M

markspace

My images are on the same directory as the classfile.

Normally, you put extra files (like images) in the source (src)
directory, not the class file directory.

Those extra files will be added to your .jar file when the .jar is built.
How to create a .jar file in eclipse?

You can also do this manually, add or remove files yourself as you please.

Can I create .zip instead of .jar will that work with applets?

If you're asking what I think you are, the answer is no. You can read a
..zip file from an applet, but I don't think you want to do that.

I found Eclipse gives no option to add images to the .jar file. Can I
use winzip to create a zip/ jar file?

Use the jar utility, that I linked to above.
 
S

Sanny

Thanks for the help.

I created a jar file with all classes. But still the applet is not5
working.

<applet code="HelloWorld.class" width="800" height="600"
archive="FightGame.jar">

FightGame.jar has a class: HelloWorld.class that runs the applet.

Here FightGame.jar is having all the files the HelloWorld.class applet
needs.

I put the html page and FightGame.jar on same folder but the applet is
not loading.

However when I put HelloWorld.class directly in that folder this
applet runs perfectly.

So the Browser is not loading FightGame.jar even though I have added
it in the <applet> tag.

Why are the classes HelloWorld.class inside FightGame.jar not working?

Incase I do not use FightGame.jar and directly put the
HelloWorld.class in the same folder the applet runs without any
problem.

Bye
Sanny
 
M

markspace

However when I put HelloWorld.class directly in that folder this
applet runs perfectly.

So the Browser is not loading FightGame.jar even though I have added
it in the<applet> tag.


I don't know about this one. Check your paths again to make sure they
are all correct. You might have to use a sniffer like Wireshark to
verify that the Java plug-in is looking where you think it is looking.
 
J

Jeff Higgins

Thanks for the help.

I created a jar file with all classes. But still the applet is not5
working.

Would the Java Console be of any use in debugging this problem?
 
S

Sanny

I don't know about this one.  Check your paths again to make sure they
are all correct.  You might have to use a sniffer like Wireshark to
verify that the Java plug-in is looking where you think it is looking.

When creating a Jar file I get below errors. I am able to play the
applet as an Application with Eclipse as it has got main() function.
But When I click the FightGame.jar It closes immidietly.

JAR creation failed. See details for additional information.
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Resource /FightGame does not exist.
Resource /FightGame does not exist
Resource /FightGame does not exist.
Problem writing /FightGame/.classpath to JAR: duplicate
entry: .classpath
Problem writing /FightGame/.project to JAR: duplicate
entry: .project
Problem writing /FightGame/HelloWorld.java to JAR: duplicate entry:
HelloWorld.java
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Problem writing /FightGame/fightgame.jardesc to JAR: duplicate
entry: fightgame.jardesc
Resource /FightGame does not exist.
Resource /FightGame does not exist.
Resource /FightGame does not exist.

Despite the errors the FightGame.jar is created.

I have kept all my images in "src" folder. I find the jar do not add
the content of "src" folder.

How to ask the Eclipse to add all files from "src" folder into the
jar.

It gives me no option to include a folder "src"

When I double click the Jar a window opens for a few sec and closes
without showing any error.

Bye
Sanny
 
L

Lew

When creating a Jar file I get below errors. I am able to play the
applet as an Application with Eclipse as it has got main() function.
But When I click the FightGame.jar It closes immidietly.

JAR creation failed. See details for additional information.
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Resource /FightGame does not exist.
Resource /FightGame does not exist
Resource /FightGame does not exist.
Problem writing /FightGame/.classpath to JAR: duplicate
entry: .classpath

Don't include .classpath in the JAR. It's a development artifact and has no
place in the deployment.
Problem writing /FightGame/.project to JAR: duplicate
entry: .project

Don't include .project in the JAR. It's a development artifact and has no
place in the deployment.
Problem writing /FightGame/HelloWorld.java to JAR: duplicate entry:
HelloWorld.java
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Problem writing /FightGame/fightgame.jardesc to JAR: duplicate
entry: fightgame.jardesc

Don't include fightgame.jardesc in the JAR. It's a development artifact and
has no place in the deployment.
Resource /FightGame does not exist.
Resource /FightGame does not exist.
Resource /FightGame does not exist.

Despite the errors the FightGame.jar is created.

I have kept all my images in "src" folder. I find the jar do not add
the content of "src" folder.

You usually don't include source in the deployment artifacts.
How to ask the Eclipse to add all files from "src" folder into the
jar [sic].
Why?

It gives me no option to include a folder "src"

That's because it isn't part of the deployment. Instead, it copies resources
FROM "src" to the build directory.
When I double click the Jar [sic] a window opens for a few sec and closes
without showing any error.

That's what the program does, apparently.
 
S

Sanny

   Problem writing /FightGame/fightgame.jardesc to JAR: duplicate
Don't include fightgame.jardesc in the JAR.  It's a development artifact and
has no place in the deployment.

I removed all unwanted files.

Still I am getting below errors.

JAR creation failed. See details for additional information.
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Problem writing /FightGame/HelloWorld.java to JAR: duplicate entry:
HelloWorld.java
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Resource /FightGame does not exist.
Resource /FightGame does not exist.
Resource /FightGame does not exist.
You usually don't include source in the deployment artifacts.

"markspace" suggested me to create a src folder and put all images
into that folder.

I wanted some way to include all images and docs needed by the applet
into a single .jar file.

How to ask the Eclipse to add all files from "src" folder into the
jar [sic].

Why?

So, that I get one .jar file instead of 20-30 images which takes
longer to download.

That's because it isn't part of the deployment.  Instead, it copies resources
FROM "src" to the build directory.

Should I put the images into "lib" folder? Or I create a build folder.
How can I suggest Eclipse to put all images into the .jar file?

When I double click the Jar [sic] a window opens for a few sec and closes
without showing any error.

That's what the program does, apparently.

No, This is a 2d fighting game When I use Run in eclipse it starts the
2d game. But when I click the .jar files the window opens for a few
sec but then closes automatically. Without showing any error.

Bye
Sanny
 
L

Lew

ATTRIBUTE YOUR CITATIONS!

You've been around this newsgroup too long not to know better, Sanny.

Sanny [etc. - work it out]:
I removed all unwanted files.

No, you didn't. Apparently you are trying to include some unwanted files more
than once.
Still I am getting below errors.

JAR creation failed. See details for additional information.
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Problem writing /FightGame/HelloWorld.java to JAR: duplicate entry:
HelloWorld.java

One does not normally include source in a JAR, or at least not in the
deployment JAR. Why do you wish to do so?
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF
Resource /FightGame does not exist.
Resource /FightGame does not exist.
Resource /FightGame does not exist.

What is "Resource /FightGame"?

What did you set for it to try to include that?

Three times?

What else have you set to cause multiple attempts to write to the JAR?

Why are you including source?
"markspace" suggested me to create a src folder and put all images
into that folder.

And nowhere did he tell you to include that folder in the JAR. You made that
part up. Don't blame him for your behavior.
I wanted some way to include all images and docs needed by the applet
into a single .jar file.

It's not by including the "src" directory, it's by copying resources into the
build directory, which Eclipse does automatically. When resrources are in the
designated source folders, Eclipse builds them into the JAR.
How to ask the Eclipse to add all files from "src" folder into the
jar [sic].

Questions should be phrased as interrogatives.

AFAIK it's enough to put the resource in the "src" folder tree, and Eclipse
copies it. I would have to check the Eclipse documentation for the details.
So, that I get one .jar file instead of 20-30 images which takes
longer to download.

That doesn't answer my question. I asked why you wish to include the "src"
directoy and you answered why you included specific image files. Including
the files makes perfect sense.
Should I put the images into "lib" folder? Or I create a build folder.

No. The Eclipse documentation explains how to set up a project.
How can I suggest Eclipse to put all images into the .jar file?

RTFM.
<http://help.eclipse.org/helios/index.jsp>
<http://help.eclipse.org/helios/inde...pse.jdt.doc.user/reference/ref-export-jar.htm>
<http://help.eclipse.org/helios/index.jsp>
<http://help.eclipse.org/helios/topi...f="build" "application" "applic" "JAR" "jar" >

and more, found within a few minutes of a search through the Eclipse
documentation online.
When I double click the Jar [sic] a window opens for a few sec and closes
without showing any error.
That's what the program does, apparently.
No, This is a 2d fighting game When I use Run in eclipse it starts the
2d game. But when I click the .jar files the window opens for a few
sec but then closes automatically. Without showing any error.

How do you know what it does? You think the same program is called by the
double-click as by Eclipse's action, but what is your evidence?

You draw a conclusion without looking at all the facts.

Appearing then disappearing when you double-click the JAR is either a failure
to associate the .jar extension with "java -jar" or a problem internal to the JAR.
 
S

Sanny

I removed all unwanted files.
No, you didn't.  Apparently you are trying to include some unwanted files more
than once.

I am using Export-> Java -> JAR File

Then I get a Window:

On One Side: FightGame
This is my package name

On Other Side

[.] .ClassPath
[.] .project

I uncheck above two files as you suggested.

When I Click [.] FightGame

I get a few more classes under it
1. (default package)
2. library classes
3. Meta-Inf

I removed the Meta-Inf files this time.

When I click (default package)On right window I get

[.] HelloWorld.java

I tried removing HelloWorld.java

But then It do not allow me to choose the Main Class: HelloWorld.
And It do not allow me to create a Jar when I disable: HelloWorld.java

Now when I Create Jar

I get below errors.

JAR export finished with warnings. See details for additional
information.
Problem writing /FightGame/HelloWorld.java to JAR: duplicate entry:
HelloWorld.java
Problem writing /FightGame/META-INF/MANIFEST.MF to JAR: duplicate
entry: META-INF/MANIFEST.MF

One does not normally include source in a JAR, or at least not in the
deployment JAR.  Why do you wish to do so?

I dont want to put HelloWorld.java But It do not allow me to choose
"Main Class" when I disable HelloWorld.java from the list.
It's not by including the "src" directory, it's by copying resources intothe
build directory, which Eclipse does automatically.  When resrources arein the
designated source folders, Eclipse builds them into the JAR.

What is the Build directory? In my workspace I cant find any "Build"
folder, Do I need to create it?
Questions should be phrased as interrogatives.

AFAIK it's enough to put the resource in the "src" folder tree, and Eclipse
copies it.  I would have to check the Eclipse documentation for the details.

I added to "src" folder too But It is not Copying to the .jar.

Bye
Sanny
 
L

Lew

ATTRIBUTE YOUR CITATIONS, SANNY!
ATTRIBUTE YOUR CITATIONS, SANNY!
ATTRIBUTE YOUR CITATIONS, SANNY!
ATTRIBUTE YOUR CITATIONS, SANNY!
ATTRIBUTE YOUR CITATIONS, SANNY!
ATTRIBUTE YOUR CITATIONS, SANNY!

Jesus H. Tapdancing CHRIST, Sanny!

Sanny wrote:

I dont want to put HelloWorld.java But It do not allow me to choose
"Main Class" when I disable HelloWorld.java from the list.

You want HelloWorld.class in the JAR, not the source.

Sanny [etc.]:
What is the Build directory? In my workspace I cant find any "Build"
folder, Do I need to create it?

It is part of the project, not the workspace, and you set it up when you set
up the project. I believe the default is "bin/" relative to your project, but
you get to rename it.

Have you read the instructions for Eclipse? It doesn't sound like you have.

Start with:
<http://help.eclipse.org/helios/topic/org.eclipse.jdt.doc.user/gettingStarted/qs-3.htm>

Note "Create separate folders for sources and class files" and "Configure
default..."

<http://help.eclipse.org/helios/topic/org.eclipse.jdt.doc.user/tasks/tasks-32.htm>

RTFM.
I added to "src" folder too But It is not Copying to the .jar.

And the Eclipse documentation says what about this? Did you read the links I
posted before? Did you?

Why did you clip all those links from your response? Did you read them?

These links will help you not at all if you don't read them. You have to read
them. Read them and study them. Learn from them when you read them. It's
the reading of them that will help you. You should probably read them. Who
knows, reading the documentation might answer your questions!

RTFM.

Please note that you could just as easily searched the help files as have me
do it for you. I found all this information in the few minutes since reading
your posts, in order to help you. You couldn't do that?

RTFM.
 

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

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top