Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #28838

Re: is that possible to include a small PNG file as part of Java class?

Path csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!border3.nntp.dca.giganews.com!backlog3.nntp.dca3.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date Tue, 24 Jun 2014 07:55:03 -0500
Date Tue, 24 Jun 2014 15:54:48 +0300
From Donkey Hottie <donkey@fredriksson.dy.fi>
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.5.0
MIME-Version 1.0
Newsgroups comp.lang.java.programmer
Subject Re: is that possible to include a small PNG file as part of Java class?
References <dd7b4b53-4f46-4b80-9cdb-a6eebac84693@googlegroups.com> <lo9l15$t3c$1@dont-email.me>
In-Reply-To <lo9l15$t3c$1@dont-email.me>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding 7bit
Message-ID <o19o7b-m97.ln1@tempest.fredriksson.dy.fi> (permalink)
Lines 47
X-Usenet-Provider http://www.giganews.com
X-Trace sv3-i2u7ghwBGE3tQIR9gBLd8ApbbaqIsl4hA1ekGh+snX4D29SW1aJpbpHMAMh5Se0Zj1UXP+xu4xgx3C0!/86k1HrtVh5T/W5SiA/pezDi5zabvd4JtwCOnoLCbwGLigjTQEEYV158lumkFrVlMxgcgQ==
X-Complaints-To abuse@giganews.com
X-DMCA-Notifications http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info Otherwise we will be unable to process your complaint properly
X-Postfilter 1.3.40
X-Original-Bytes 3221
Xref csiph.com comp.lang.java.programmer:28838

Show key headers only | View raw


23.06.2014 19:35, Martin Gregorie kirjoitti:
> On Mon, 23 Jun 2014 09:02:20 -0700, www wrote:
> 
>> Hi:
>>
>> I have a simple Java class: Abc.java. The method within it needs to
>> access a small PNG file(it's an icon picture). Right now, this picture
>> file("abc.png") is located at nonsrc/icons/abc.png
>>
>> So this class is a bit pain. Abc.class won't work in the absence of
>> abc.png. When I create an executable JAR, this is pain: always need to
>> remember to include abc.png file inside it.
>>
>> I am wondering if there is a way that I can "convert" abc.png into some
>> sort of Java code and I can put it in Abc.java. So Abc.class alone can
>> perform the job, without the need of presence of abc.png. Is that
>> possible?
>>
> Not that I'm aware of.
> 
> Why not turn the problem up the other way? Include the image file 
> somewhere inside the package level directory that contains Abc.class and 
> use ant to run the compilation and, if that succeeds, assemble the jar 
> file.
> 
> It sounds as though you don't use ant or maven to run your compiles. I 
> use ant, which is fairly easy to learn. Using it has the advantave that 
> once you've set it up to compile a package hierarchy and create a jar 
> file containing it, you can easily add/rename/scrap classes etc without 
> changing the build file, which is what you create to tell ant what you 
> want it to do: once its set up, compilation, javadocs and jar creation 
> are all handled automatically by the "ant" command.
> 
> 

Of course it is possible to include an image to a Java file. Just create
a tool which will take an image as input and write a fragment of Java
source as byte[] image = {...<contents of the image>...} ;

That was very common one when we wrote programs in C/C++ and it should
work now too.


-- 

The fashion wears out more apparel than the man.
		-- William Shakespeare, "Much Ado About Nothing"

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

is that possible to include a small PNG file as part of Java class? www <xsli2@yahoo.com> - 2014-06-23 09:02 -0700
  Re: is that possible to include a small PNG file as part of Java class? Martin Gregorie <martin@address-in-sig.invalid> - 2014-06-23 16:35 +0000
    Re: is that possible to include a small PNG file as part of Java class? Donkey Hottie <donkey@fredriksson.dy.fi> - 2014-06-24 15:54 +0300
      Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-24 10:07 -0400
      Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-24 10:49 -0400
      Re: is that possible to include a small PNG file as part of Java class? Roedy Green <see_website@mindprod.com.invalid> - 2014-06-25 01:25 -0700
  Re: is that possible to include a small PNG file as part of Java class? Marcel Müller <news.5.maazl@spamgourmet.org> - 2014-06-23 18:25 +0200
  Re: is that possible to include a small PNG file as part of Java class? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-06-23 13:03 -0400
    Re: is that possible to include a small PNG file as part of Java class? Wanja Gayk <brixomatic@yahoo.com> - 2014-06-29 11:14 +0200
      Re: is that possible to include a small PNG file as part of Java class? Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-06-29 08:15 -0400
  Re: is that possible to include a small PNG file as part of Java class? markspace <markspace@nospam.nospam> - 2014-06-23 10:39 -0700
  Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 15:04 -0400
    Re: is that possible to include a small PNG file as part of Java class? Roedy Green <see_website@mindprod.com.invalid> - 2014-06-25 01:34 -0700
  Re: is that possible to include a small PNG file as part of Java class? Joerg Meier <joergmmeier@arcor.de> - 2014-06-23 21:15 +0200
    Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 15:46 -0400
      Re: is that possible to include a small PNG file as part of Java class? Joerg Meier <joergmmeier@arcor.de> - 2014-06-23 22:08 +0200
        Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 16:19 -0400
          Re: is that possible to include a small PNG file as part of Java class? Joerg Meier <joergmmeier@arcor.de> - 2014-06-23 22:34 +0200
            Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 16:43 -0400
              Re: is that possible to include a small PNG file as part of Java class? Joerg Meier <joergmmeier@arcor.de> - 2014-06-24 00:21 +0200
                Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 21:02 -0400
                Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 21:10 -0400
                Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 21:23 -0400
                Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-24 16:17 -0400
          Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-23 16:33 -0400
        Re: is that possible to include a small PNG file as part of Java class? Jeff Higgins <jeff@invalid.invalid> - 2014-06-24 16:00 -0400
  Re: is that possible to include a small PNG file as part of Java class? Andreas Leitgeb <avl@auth.logic.tuwien.ac.at> - 2014-06-24 17:17 +0000
  Re: is that possible to include a small PNG file as part of Java class? Roedy Green <see_website@mindprod.com.invalid> - 2014-06-24 11:11 -0700

csiph-web