Path: csiph.com!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Martin Gregorie Newsgroups: comp.lang.java.programmer Subject: Re: is that possible to include a small PNG file as part of Java class? Date: Mon, 23 Jun 2014 16:35:49 +0000 (UTC) Organization: A noiseless patient Spider Lines: 37 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Mon, 23 Jun 2014 16:35:49 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="e5160e2be48f1ea550cf61512446f525"; logging-data="29804"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19GW759WYq9wL09hyl7CfR29rlsHa4pAFI=" User-Agent: Pan/0.139 (Sexual Chocolate; GIT bf56508 git://git.gnome.org/pan2) Cancel-Lock: sha1:BJ0PeE9lc20z/ewBHpSZZiqHpKg= Xref: csiph.com comp.lang.java.programmer:28822 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. -- martin@ | Martin Gregorie gregorie. | Essex, UK org |