by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Alessandro Pignotti
    @alexp-sssup
    @dac2k9_twitter You will probably find this page interesting: https://github.com/leaningtech/cheerpj-meta/wiki/WebWorker-API
    dac2k9
    @dac2k9_twitter
    Thank you! Will check
    Thesanjayrai
    @Thesanjayrai
    Hi
    I just downloaded CheerpJ
    and also Pyhton3
    Please help me, how to use it
    Carlo Piovesan
    @carlopi
    @Thesanjayrai: I would recommend first to follow the tutorial here: https://github.com/leaningtech/cheerpj-meta/wiki/Tutorial using it at first for converting the TextDemo.jar provided there, and then follow the same steps with your own jar file. If at any point you are stuck, just describe what you have done/where you feel stuck and someone will help!
    Thesanjayrai
    @Thesanjayrai
    Hi @carlopi I'm stuck at Build the JAR.JS file

    CheerpJ provides a convenient python program to convert whole JARs to JavaScript: cheerpjfy.py. It supports several options for advanced users, but it's basic syntax is very simple. The following command will generate TextDemo.jar.js

    cd ~/cheerpj_tutorial/
    ~/cheerpj_2.1/cheerpjfy.py TextDemo.jar

    How do i do this.
    cd ~/cheerpj_tutorial/
    ~/cheerpj_2.1/cheerpjfy.py TextDemo.jar
    Can u help me with remote session. I can learn from there. I'm confused right now tho
    Thesanjayrai
    @Thesanjayrai

    I launch Python

    import os
    os.startfile("D:\Testing")

    sorry previous wrong..
    Thesanjayrai
    @Thesanjayrai

    I launch Python

    import os
    os.startfile("D://Testing")
    os.startfile("D://cheerpj_2.1/cheerpjfy.py TextDemo.jar")

    But i got an error FileNotFoundError: [WinError 2] The system cannot find the file specified: 'D://cheerpj_2.1/cheerpjfy.py TextDemo.jar'

    Carlo Piovesan
    @carlopi
    @Thesanjayrai: you seem to be using python's command line, while the intended usage is from the system's command line.
    On Windows for example, it requires to follow the following steps: "Press Windows+R to open “Run” box. Type “cmd” and then click “OK” to open a regular Command Prompt".
    Then, on the command line that opens, you move to the folder where the example is located, and then you write "/path/to/cheerpj_2.1/cheerpjfy.py TextDemo.jar"
    Thesanjayrai
    @Thesanjayrai
    I'm confused this part ... and then you write "/path/to/cheerpj_2.1/cheerpjfy.py TextDemo.jar"
    i got 2 folder
    D:\cheerpj_2.1\cheerpjfy.py
    D:\Testing
    In D:\Testing\TextDemo.jar ........... testdemo.jar located in testing folder
    Thesanjayrai
    @Thesanjayrai
    In CMD.
    C:\Users\Rajveer Rai>D:
    D:>cd Testing
    D:\Testing>D:\cheerpj_2.1\cheerpjfy.py
    Usage: D:\cheerpj_2.1\cheerpjfy.py file.jar
    When ever i put TestDemo.jar, I'll receive error
    Alessandro Pignotti
    @alexp-sssup
    @Thesanjayrai You forgot to add TextDemo.jar to the command
    Rick Mabry
    @rmabry_gitlab

    I have successfully installed CheerpJ on Centos 7, converted a jar file , used it to convert and run an applet that worked in the days of java (and still works in IE). I used the commands on the Getting Started page under "Converting an applet".

    The CheerpJ'd version works beautifully except for a few things. The main one: I can still pass commands to the applet via javascript and it seems to work perfectly. But I can no longer receive data via javascript calls such as this to the applet:

    applet.getSomething()

    The returned object is always an [object Promise]. On the other hand, calls like

    applet.setSomething(value)

    seem to work fine.

    The applet is initialized, has been sitting for many minutes responding to other commands. Only these "get" commands fail. (Caveat: this is my first encounter with a Promise object, so ancient is my knowledge.) I did also try, out of curiosity, to look at the returned value of cheerpjInit(), not knowing if anything would be returned at all. The result was also an [object Promise].

    What should I be doing?

    Alessandro Pignotti
    @alexp-sssup
    The legacy Java plugin could block JS execution to run arbitrary code in Java when a method is called
    this is now forbidden by the browser and CheerpJ does its best to provide compabitibility within the limitation of the platform
    the easiest solution is to change you code to wait for the promise to be fullfilled
    getSomething().then(function(actualResult){...})
    You can also use modern async/await JS programming to write this code more conveniently
    var result = await applet.getSomething()
    Rick Mabry
    @rmabry_gitlab
    Thanks, I'll give it a try.
    Rick Mabry
    @rmabry_gitlab

    Progress: I wasn't immediately able to get the "await" version to work, so rather than awaiting a better understanding, I tried the "Promise/then" version and got something that I can live with pretty easily. But I do have another question:

    The successful return was not in the form of data; it was an Object. I stringify'd it to see that it is returning a field called "value0":

    {"value0":1.93}

    So I can get my goodies with

    obj.value0

    in this case. But whose "value0" is this? That is, who named it? Is it from CheerpJ? If so, where is this described and is it here to stay? And how do I know what other sorts of fields to expect, if any, with other such calls?

    Rick Mabry
    @rmabry_gitlab
    Yes, an Object is data, lest someone beat me to pointing that out. Instead of saying that the return "was not in the form of data; it was an Object", I should have said that it was not in the original form of the data (a string or number), but rather, that data was now part of a larger Object.
    Alessandro Pignotti
    @alexp-sssup
    @rmabry_gitlab This is a bug, the value returned is a "boxed" Java object. The internal member "value0" is how CheerpJ represent the member of the boxed object
    This is an implementation detail, in the future it may change. The good news is that if you use a specific version of the CheerpJ runtime that works for your content, then it will work forever. Our releases are immutable.
    I have written down this bug in our internal bug tracking system, unfortunately we are a small company and currently working at capacity for our customers, so I am able to prioritize working in this bug in the short term.
    Rick Mabry
    @rmabry_gitlab

    @alexp-sssup Good to know, many thanks for the speedy info. Speaking of speed, that is my other concern. The loading time is very high, at least the first time CheerpJ is encountered by each browser. If someone comes to my website to simply have a quick look at an object, many would probably leave rather than wait so long. In fact, I had to wait different amounts of time as I tested various browsers. The ones I tested eventually worked, but some seemed to require refreshing a few times. (In one case I walked away to have dinner and there was no change when I came back, but I do not recall the message being displayed at the time, sorry.) Is this a result of my using the version that requires loading from your website?

    <script src="https://cjrtnc.leaningtech.com/2.1/loader.js"></script>

    Any advice about that?

    Alessandro Pignotti
    @alexp-sssup
    Did you use the CheerpJ AOT compiler?
    i.e. do you have jar.js for each of your jars?
    That is crucial to achieve high perf, otherwise CJ needs to compile all your code at runtime every execution
    Beside this there are several things you have to do to improve startup time, in particular set up preloading
    Rick Mabry
    @rmabry_gitlab

    @alexp-sssup

    do you have jar.js for each of your jars?

    Yes, just one jar compiled into one jar.js, both in the same directory.

    Beside this there are several things you have to do to improve startup time, in particular set up preloading

    Thanks. I have now tried preloading.

    If my (few) experiments with Firefox and Edge are correct (clearing cache and reloading the cheerpjfy'd app), the initial load time today (*) has gone from around 60 seconds to about 10-15 seconds, pretty good! But...

    I had already enabled Gzip compression (it was not previously enabled), but that didn't seem to help. Maybe because the jar.js file isn't so big (about half a megabyte)? In any case, today's loading time is a big improvement. But I am not sure how much the preloading (using the ouput of cjGetRuntimeResources()) is the reason, because when I switch between preloading and the default, I cannot tell a difference in the loading time. Could Leaningtech traffic play any role?

    And whether I preload or not, I still get poor marks from Google's PageSpeed Insights (around 25 out of 100) in all of these cases, with a long list of deficits attributed to Leaningtech files and such.

    (*) Another experiment: In a "Private Window" in Firefox, all I got was the CheerpJ "loading" image for over five minutes. I closed it. I tried that again, for over 10 minutes. Nothing. But I will not concern myself with that.

    For the typical browsers, after the initial loading following a cleared cache, load time is around 3-5 seconds. I'll probably be okay with that for my purposes.

    Alessandro Pignotti
    @alexp-sssup
    The CheerpJ runtime is hosted on the global CDN cloudflare, it's is extremely unlikely that an high server load is slowing down the download. The improvement is 100% due to preloading. Please understand that when using native Java the user would have separately downloaded 100s MB of Java installer before, and CheerpJ needs to deliver an equivalent runtime on the fly.
    Firefox private browsing does not allow the use of IndexedDB Web API, which CheerpJ uses to store "persistent" files.
    Chrome incognito on the other hand allow the use of the API and simply wipes out the DB afterwards
    Supporting Firefox private mode is possible, it is simply something that we have done yet due to no commercial demand.
    We are a small company, so we have to prioritize what is needed by our commercial users
    CheerpJ can notify you of the loading progress (build on the top of the preloading system), so that you can offer your users a better integration if you wish
    Bruno Eberhard
    @BrunoEberhard
    Hi Alessandro. I again experiment with Cheerpj. This time Version 2.1. At the moment I get "Can't find resource for bundle java.util.PropertyResourceBundle".
    I have Java 11 installed but set compile target in maven pom.xml to 1.8 .
    Second problem: I tried to use cheerpjRunMain(..).then(function) . But function is always called immediately.