Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Creating Archive Files in Eclipse with images.

Reply
Thread Tools

Creating Archive Files in Eclipse with images.

 
 
Sanny
Guest
Posts: n/a
 
      05-18-2011
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
 
Reply With Quote
 
 
 
 
markspace
Guest
Posts: n/a
 
      05-18-2011
On 5/18/2011 5:16 AM, Sanny wrote:

> 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.

<http://download.oracle.com/javase/tutorial/deployment/jar/>


> 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.

<http://download.oracle.com/javase/6/docs/api/java/util/zip/ZipInputStream.html>


> 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.
 
Reply With Quote
 
 
 
 
Sanny
Guest
Posts: n/a
 
      05-19-2011
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
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      05-19-2011
On 5/19/2011 10:20 AM, Sanny wrote:

> 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.

 
Reply With Quote
 
Jeff Higgins
Guest
Posts: n/a
 
      05-19-2011
On 05/19/2011 01:20 PM, Sanny wrote:
> 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?


 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      05-19-2011
On 5/19/2011 10:20 AM, Sanny wrote:
> Why are the classes HelloWorld.class inside FightGame.jar not working?


I found this, it might help you with some definitive answers:

<http://download.oracle.com/javase/6/docs/technotes/guides/plugin/developer_guide/contents.html>


 
Reply With Quote
 
Sanny
Guest
Posts: n/a
 
      05-20-2011
> 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

 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      05-20-2011
On 05/20/2011 05:20 AM, Sanny wrote:
>> 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


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.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
Sanny
Guest
Posts: n/a
 
      05-20-2011
> > * *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.


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.

> > 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.


"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.


> > 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.


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
 
Reply With Quote
 
Lew
Guest
Posts: n/a
 
      05-20-2011
ATTRIBUTE YOUR CITATIONS!

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

Sanny wrote:
>>> Problem writing /FightGame/fightgame.jardesc to JAR: duplicate
>>> entry: fightgame.jardesc


Lew wrote:
>> Don't include fightgame.jardesc in the JAR. It's a development artifact and
>> has no place in the deployment.


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?

>>> 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.


> "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.

>> Why?

>
> 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.

>>> 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.


> 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/index.jsp?topic=/org.eclipse.jdt.doc.user/reference/ref-export-jar.htm>
<http://help.eclipse.org/helios/index.jsp>
<http://help.eclipse.org/helios/topic/org.eclipse.jdt.doc.user/reference/ref-properties-build-path.htm?resultof=%22%62%75%69%6c%64%22%20%22%61%7 0%70%6c%69%63%61%74%69%6f%6e%22%20%22%61%70%70%6c% 69%63%22%20%22%4a%41%52%22%20%22%6a%61%72%22%20>

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.

--
Lew
Honi soit qui mal y pense.
http://upload.wikimedia.org/wikipedi.../c/cf/Friz.jpg
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Creating Calendars for a Web Archive Help Request RC Gray HTML 3 12-28-2011 04:54 AM
Eclipse not picking modified files that where change outside eclipse... karmjunk@gmail.com Java 1 09-11-2006 04:10 AM
[eclipse 3.1] how to 'export' an 'external archive' ? Pierre Java 2 02-25-2006 11:52 PM
Nokia + Eclipse: creating JAR files from eclipse John Goche Java 2 01-22-2006 01:53 AM
How to list (from command line) all files in a "jar" archive ? Thomas Stien Java 4 02-09-2005 03:54 PM



Advertisments