3

I have a created a sample application using javafx. Due to certain restrictions in my network, I cannot install fxpackaging tools such at e(fx)clipse etc.

I have created jar using eclipse(version 4.5.1) application works perfectly when I execute jar file using below command in cmd

java -jar myjarfile.jar

Problem 1 :(resolved)

I have observed this exception in 'command prompt'

java.net.MalformedURLException: Coult not open InputStream for URL 
'rsrc:application/application.bss'

I have created bss files using below command(executed at project root level)

javafxpackager -createbss -srcfiles application.css -outdir .

Then copied the output bss file to proper location(program excepts resource located a specific folder).

Problem 2: (not resolved)

Initial exception has been resolved & I could see the fonts are displayed as expected. But in the background I could see below exception

java.io.IOException: rsrc:application/application.bss wrong binary CSS version: 5. Expected version less than or equal to3

Question:

How to fix this 'wrong binary CSS version' exception(displayed in command prompt)? Please note, I don't see any issues with application,which is running in foreground.

For testing purpose I have used a one liner styling code in my application.css file

.label{-fx-text-fill: black;}

→ jar file created using eclipse (JDK 1.7) & windows is running on JRE 1.7.0_91

css file : one liner as mentioned above

css file

bss file bss file

package structure

package

Raju
  • 2,902
  • 8
  • 34
  • 57
  • Could you post your JDK versions: the one used to create the project, and the bss file, and the one you are running your project with (`java -version`)? – José Pereda Mar 14 '16 at 17:05
  • @JoséPereda, Jar file created using eclipse (having jdk 1.7) and application.bss created using windows JRE version 1.7.0_91 – Raju Mar 14 '16 at 23:55
  • Can we see the bss file that is causing this exception? – Abob Mar 15 '16 at 00:05
  • @Abob78, I have attached images to my question. For testing purpose, I have put only a label in my *.css file. – Raju Mar 15 '16 at 00:11
  • Do you have a JDK8 installed? Make sure you are not using it. – José Pereda Mar 15 '16 at 00:26
  • Your syntax is fine, so it must be how the css file was compiled that's causing the problem. You said you couldn't install anything, but could you update eclipse with the javafx packages by adding a repo (requires no admin priveledges)? – Abob Mar 15 '16 at 00:31
  • @JoséPereda, I have installed JDK1.8 in my desktop, but I have selected jdk1.7 in eclipse, I have configured my windows PATH variable to JRE 1.7 – Raju Mar 15 '16 at 00:31
  • @Abob78, our corporate network restricts direct internet access. I cannot add any plugins beyond the software provided to us. – Raju Mar 15 '16 at 00:33
  • @Raju okay, that's fine. To clarify, is every related file class and css file in the jar? Are both `application.bss` and `application.class` in the same place inside your jar? Or are you using fxml for everything? Basically, whats does the inside of your jar look like? – Abob Mar 15 '16 at 00:38
  • @Abob78, My jar has all the necessary files – Raju Mar 15 '16 at 00:46
  • @Abob78,@JoséPereda I have posted my observation in the answer. This is not full solution, because the utility is supposed to run in JRE 1.7 & above. Can you check, if you can help me with this observation. – Raju Mar 15 '16 at 00:54

2 Answers2

2

As José Pereda stated, bss is version 5 on Java 8. Based on the JavaFX 8 CSS Reference Guide for label, the syntax is correct. However, this is for Java 8, while you are currently using Java 7. If you have Java 8, configure eclipse and set the build path to use it and set your PATH variable accordingly to Java 8.

If the problem persists:

If it's not working even after the update, we'll try to compile it slightly differently to see what happens. According to this post, you don't need the .css file once you have compiled the .bss file.

Create a Test folder somewhere easily accessible. We'll be using this to see how the files being compiled separately will effect the exception since updating Java has done nothing at this point.

First, try to run the program with the essential files. If your Main.java file doesn't rely on the other java files in your project, then copy that file in to the test folder we recently created. If not, copy only the necessary parts that use the css (such as the scene and label that calls the css file), and paste that into a new Main.java in the new test folder.

Continuing forward you're going to have to open a command window in your test folder. You can do this by pressing SHIFT + RIGHT CLICK in the test folder on Windows Explorer and click Open command window here

After this, compile Main.java by typing this in the newly opened commnd prompt window:

javac Main.java

Next, copy appication.css but rename it to Main.css, for testing purposes. Then, run this in the command prompt window (You didn't have the -outfile arguement; this shouldn't matter, but it's a slight safety measure):

javafxpackager -createbss -srcfiles Main.css -outdir . -outfile Main

Now you should see that you have Main.css. Now, with the same command window you can easily run the file and see what happens.

java Main

Please leave a comment if this help you and which part of this answer you actually used to fix the problem if this answer did help you, thanks!

Community
  • 1
  • 1
Abob
  • 751
  • 5
  • 27
  • I would like to fix my issue before finishing the formalities of this question ;) I have installed JDK 1.7.0_76, unfortunately it is not generating any bss file. It is not even showing any error. I will try with JDK 1.7.0_79 & let you know my finding. – Raju Mar 16 '16 at 01:03
  • test with jdk 1.7.0_95 , javafxpackager is not throwing any error & not creating any files at all :( – Raju Mar 19 '16 at 17:06
  • packager is not working it seems. [screenshot reference](http://i.stack.imgur.com/WCOr0.png) – Raju Mar 19 '16 at 17:13
  • Looks like there is a bug with javafxpackager, but the rootcause was found, hence I am awarding bounty. Thanks @Abob78 – Raju Mar 19 '16 at 17:25
0

Based on the comments from José Pereda, Abob78 I did an experiment. I have figured it out that, the issue is not observed if I am using JRE 1.8

  1. Command prompt 1 : pointed JRE 1.7.0_91 → above exception observed
  2. Command prompt 2 : pointed JRE 1.8.0_40 → exception not observed.

Both running at same time & using same JAR file.

Raju
  • 2,902
  • 8
  • 34
  • 57
  • 2
    Bss level 5 is from JDK8, so that's why you don't get the issue running JDK8. The question remains: where do you run the javafxpackager from? – José Pereda Mar 15 '16 at 00:56
  • @JoséPereda, that's a good catch. I think, that's the root cause of the issue. Though JRE is pointing to 1.7 directory, when I run `where javafxpackager.exe` it is pointing to JDK 1.8 directory. – Raju Mar 15 '16 at 01:09
  • Make sure you run it from the JDK7 distribution, and check again, if it works I'll write a proper answer – José Pereda Mar 15 '16 at 01:12
  • @JoséPereda, I have these java versions available in my system jdk1.6.0_31,jdk1.6.0_39,jdk1.7.0_25,jdk1.8.0_40,jdk1.8.0_51,jre7. Unfortunately, javafxpackager.exe is available in jdk1.8(2 directories) only. This utility should work in JRE1.7 and above. Is this possible ? – Raju Mar 15 '16 at 01:16
  • JDK 1.7.0_65 to the latest 1.7.0_79 all have javafxpackager. You may need to upgrade your JDK7 version. – José Pereda Mar 15 '16 at 01:23
  • @Raju Glad to hear that it seems to be just the version of java! As a side note, 1.8.0_74 is the latest version of Java at the time of this comment. I suggest updating, but if you can't at least delete JDK 1.7 off the computer so it doesn't interfere. It will also allow you to see what needs to be re-configured, since it will give you errors if you missed something. – Abob Mar 15 '16 at 01:33
  • @Abob78, This utility is supposed to work in multiple java versions. So, I am maintaining all the versions to test the utility in all the java versions. – Raju Mar 15 '16 at 01:41
  • According to [this](https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javafxpackager.html), `javafxpackager` is only avaliable on java 8 and could possibly be named `javapackager`. Below Java 8, you would have to use [native bundles](https://blogs.oracle.com/talkingjavadeployment/entry/native_packaging_for_javafx) – Abob Mar 15 '16 at 01:54