We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › accessing file inside jar archive
Page Index Toggle Pages: 1
accessing file inside jar archive (Read 2161 times)
accessing file inside jar archive
May 27th, 2009, 5:35am
 
Hi,
I use a PApplet as part of an Java Application. This PApplet uses own fonts (as *.ttf) included in a data folder inside the jar file. Running the Application from Eclipse works fine and the font i loaded from the data folder.
Running the compiled jar file does not work, since the path of the font is:

Code:
C:/BC.jar!/BC/data 



the path is generated with

Code:
this.getClass().getResource("data/").getPath() 

.

processing does not load the font via

Code:
PFont test = createFont("C:/BC.jar!/BC/data/myFont.ttf"); 




Is there any possibility to access data inside the compiled jar file? It will be great, because the application will not depend on any special data (font) folders on the running machine.

Thanks,
Stefan





Re: accessing file inside jar archive
Reply #1 - May 27th, 2009, 9:01am
 
Have you tried just createFont("myFont.ttf");?
(I haven't, just wondering...)
Re: accessing file inside jar archive
Reply #2 - May 27th, 2009, 1:14pm
 
I have used createInput(filename) to access files packaged into the .jar file from the data directory.  I think if you're trying to load a font from that directory, what you want is loadFont(fontname).
Re: accessing file inside jar archive
Reply #3 - May 28th, 2009, 2:32am
 
none of the methods worked. i generated a myFont.vlw file and tries to read it using loadFont, but without success.

are there solutions for other files to be read by processing, beeing embedded into the final jar file?

thanks,
stefan
Re: accessing file inside jar archive
Reply #4 - May 28th, 2009, 7:41am
 
It sounds as if you're building your .jar file using Eclipse, which I haven't used.  Have you tried using the Processing IDE to compile your project?  loadFont() or createInput() should work.  I suspect that whatever steps you're using to build the .jar file may not be including files from the data directory properly.
Page Index Toggle Pages: 1