Jump to content
Excelsior Forums
shashaank

Package Java 8 application with javafx ui with java runtime in less than 5 MB

Recommended Posts

Hi,

I am extremely excited to share something unimaginable.

Java 8 FX app in less than 5MB !!!!!

This allows me to use functional programming and other goodies as well !!!!

Don't believe me, just see it for yourself :

https://github.com/shashaanktulsyan/spyfs/blob/master/sample%205MB%20java%20application.7z'>https://github.com/shashaanktulsyan/spyfs/blob/master/sample%205MB%20java%20application.7z

Note : this is a 64bit application, so don't be surprised if this doesn't run on 32bit oses. Also it is based on java8 so it might show error on older versions of windows.

I am sure you are also wondering what wizardry I have used here.

Let me tell what I did. I used following this to my advantage :

  1. Java classes are loaded in lazy fashion. So even if there is dependency to a class because of an import statement, the class itself will not be loaded until it is required !
  2. Xbootclasspath can be used to change runtime classes. So instead of using heavy rt.jar and other heavy jar files we can use a highly stripped down runtime which has exactly those classes which we require.
  3. So now the last part remains, is how to find which classes are actually used. For this purpose I don't use anything related to javavm. Instead I use virtual filesystems!!! This way I am also able to remove native libraries (dlls) and resources (configuration files etc) which are not required.
  4. Finally these options can be set very easily in configuration file of a native java application created using javafx packager. Only 2 lines need to be added to do the trick.

Here I am not going to share the details.

But I am here to share the excitement. This is really insanely small !

A Javafx application in 5MB!! That is crazy small.

What do you guys think?

Hopefully even Excelsior could benefit from this cool technology things which I just developed.

BTW if you are interested in knowing the exact steps, check out https://github.com/shashaanktulsyan/spyfs .

Thanks

Shashank :D :D :D

Share this post


Link to post
Share on other sites

Do you think this is possible with excelsior jet?

Can we further strip down the size of the executable produced by excelsior using

a smaller bootstrap runtime?

Hi,

I am extremely excited to share something unimaginable.

Java 8 FX app in less than 5MB !!!!!

This allows me to use functional programming and other goodies as well !!!!

Don't believe me, just see it for yourself :

https://github.com/shashaanktulsyan/spyfs/blob/master/sample%205MB%20java%20application.7z'>https://github.com/shashaanktulsyan/spyfs/blob/master/sample%205MB%20java%20application.7z

Note : this is a 64bit application, so don't be surprised if this doesn't run on 32bit oses. Also it is based on java8 so it might show error on older versions of windows.

I am sure you are also wondering what wizardry I have used here.

Let me tell what I did. I used following this to my advantage :

  1. Java classes are loaded in lazy fashion. So even if there is dependency to a class because of an import statement, the class itself will not be loaded until it is required !
  2. Xbootclasspath can be used to change runtime classes. So instead of using heavy rt.jar and other heavy jar files we can use a highly stripped down runtime which has exactly those classes which we require.
  3. So now the last part remains, is how to find which classes are actually used. For this purpose I don't use anything related to javavm. Instead I use virtual filesystems!!! This way I am also able to remove native libraries (dlls) and resources (configuration files etc) which are not required.
  4. Finally these options can be set very easily in configuration file of a native java application created using javafx packager. Only 2 lines need to be added to do the trick.

Here I am not going to share the details.

But I am here to share the excitement. This is really insanely small !

A Javafx application in 5MB!! That is crazy small.

What do you guys think?

Hopefully even Excelsior could benefit from this cool technology things which I just developed.

BTW if you are interested in knowing the exact steps, check out https://github.com/shashaanktulsyan/spyfs .

Thanks

Shashank :D :D :D

Share this post


Link to post
Share on other sites

Do you think this is possible with excelsior jet?

Can we further strip down the size of the executable produced by excelsior using

a smaller bootstrap runtime?

Excelsior JET actually had such technology since the second public beta and up to and until version 3.7. It was called JetPerfect, and it enabled you to cram an SWT app onto a 1.44MB floppy disk. But there were two big problems with it:

  • It was extremely fragile - any use of reflection or JNI at run-time could break things completely. One client compiled their SWT app on a system where the mouse had no wheel, and it blew up on its client's systems when SWT tried to load the respective class dynamically.
  • It was illegal - the Java SE license did not permit subsetting the API. (It still does not, with the exception of Compact Profiles introduced in Java 8, but, of course, today you can just take OpenJDK and throw away whatever you want.)

That's why we dropped JetPerfect from version 4.0, which was the first certified Java Compatible. But even if there were no legal issues, the wheel-less mouse incident alone would have been enough to trigger the decision.

Share this post


Link to post
Share on other sites

Excelsior JET actually had such technology since the second public beta and up to and until version 3.7. It was called JetPerfect, and it enabled you to cram an SWT app onto a 1.44MB floppy disk. But there were two big problems with it:

  • It was extremely fragile - any use of reflection or JNI at run-time could break things completely. One client compiled their SWT app on a system where the mouse had no wheel, and it blew up on its client's systems when SWT tried to load the respective class dynamically.
  • It was illegal - the Java SE license did not permit subsetting the API. (It still does not, with the exception of Compact Profiles introduced in Java 8, but, of course, today you can just take OpenJDK and throw away whatever you want.)

That's why we dropped JetPerfect from version 4.0, which was the first certified Java Compatible. But even if there were no legal issues, the wheel-less mouse incident alone would have been enough to trigger the decision.

Thank you :D

You saved me from putting efforts in this.

A few days after posting on excelsior I was also feeling that this idea is not so good, and java9 modularization would be far more better (which I suppose would trickle down to excelsior in some way)

Thank again.

Share this post


Link to post
Share on other sites

Thank you :D

You saved me from putting efforts in this.

A few days after posting on excelsior I was also feeling that this idea is not so good, and java9 modularization would be far more better (which I suppose would trickle down to excelsior in some way)

Thank again.

And moreover there is a safe solution that is implemented in Excelsior JET eight years ago -- http://www.excelsiorjet.com/solutions/java-download-size

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×