Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Exporting problems! Please help!  (Read 15340 times)

0 Members and 1 Guest are viewing this topic.

gasquakee

  • Newbie
  • *
  • Posts: 7
    • View Profile
Exporting problems! Please help!
« on: December 12, 2015, 01:57:46 am »
Hey guys,

So my experience with jSFML has been absolutely superb but I'm having some problems whilst making a jar. I can make my jar and and run it but none of my assets go through; Instead, they are replaced with White rectangles. Does anyone know what's going on? I'd really appreciate it! Thank you.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Exporting problems! Please help!
« Reply #1 on: December 12, 2015, 06:07:11 pm »
The paths to the assets are probably wrong. Make sure they're still valid in the JAR.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: Exporting problems! Please help!
« Reply #2 on: December 12, 2015, 11:14:25 pm »
Indeed, as Nexus said, the file structure of your exported version seems to be different from your IDE.
How do you load resources, via classpath or from the file structure? Maybe post a little code sample, giving us some insight on the way you load your textures, for instance.
JSFML - The Java binding to SFML.

gasquakee

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Exporting problems! Please help!
« Reply #3 on: December 12, 2015, 11:36:21 pm »
I load resources like this:
try {
   spritesheet.loadFromFile(Paths.get("res/spritesheet.png"));
} catch (Exception e) {
   e.printStackTrace();
}

and I add a class folder in eclipse called "res"

This seems right to me? Could it be how I export it? I export a runnable jar file and I extract libraries into a generated jar according to Eclipse.

side note: is jSFML still being worked on?

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: Exporting problems! Please help!
« Reply #4 on: December 13, 2015, 01:37:23 am »
Quote
spritesheet.loadFromFile(Paths.get("res/spritesheet.png"));

This means that you are reading the texture from the filesystem, not the classpath.
In your released version, you would need a directory called "res" with the file in it, it won't work in the jar.

You need to load it from the classpath / jar, using the loadFromStream method using the path to the resource (look that up, easy to find information :) ).

Quote
side note: is jSFML still being worked on?
Ouch. ;D

At the moment, no. Most SFML 2.2 changes had been incorporated, but I never made an official build because I had no environment set up. I completely lost track of what's going on when 2.3 was released, because I have no use for SFML myself at the moment.

I also said goodbye to Java after quitting a job in summer, so the situation is not exactly great for JSFML. :(
If somebody's willing to take over, that'd probably be best for the project. For now, I can only help with what's there.
JSFML - The Java binding to SFML.

gasquakee

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Exporting problems! Please help!
« Reply #5 on: December 13, 2015, 04:59:24 am »
Thank you!

Also, though, sad. How would you say the current version of jSFML is though? I've used it for a little over a month now and I like it quite nice. When do you think it will be too old?

gasquakee

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Exporting problems! Please help!
« Reply #6 on: December 13, 2015, 05:18:46 am »
Hmm, I've replaced what you've told me to and I can run it through CMD as a jar but I cant run it via double click?

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
Re: Exporting problems! Please help!
« Reply #7 on: December 14, 2015, 09:51:40 am »
Quote
Thank you!

Also, though, sad. How would you say the current version of jSFML is though? I've used it for a little over a month now and I like it quite nice. When do you think it will be too old?
The problem is that bugfixes from the updated SFML do not go in there, so whatever problems SFML 2.1 had are in the current JSFML. It works pretty decent as far as I can tell, though.

Of course, SFML 2.2 and 2.3 brought an improved API, too, which is not in JSFML.

Quote
Hmm, I've replaced what you've told me to and I can run it through CMD as a jar but I cant run it via double click?
That's system specific, you'll need to associate JAR files to Java. If the setup doesn't do it automatically (I think only the JRE setup does, not the JDK one), then you have to do it manually.

That goes for customers, too.

You could alternatively create a batch file for launching it, or use launch4j to create an executable launcher.
JSFML - The Java binding to SFML.

gasquakee

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Exporting problems! Please help!
« Reply #8 on: December 16, 2015, 01:52:19 am »
Yeah, I was thinking about batch I just didn't know how many OS' supported it. I'll look into launch4j.

 

anything