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
    Please understand that, by our policies, we cannot provide free support (as part of the CheerpJ Applet Runner extension) for applets on private networks or behind logins. We are happy to do so for commercial customers.
    Bill Mollett
    @bmollett_gitlab
    Sorry, the applet belongs to a non-profit organization (Gemstone Vision). Their server is down. I'll see if I can get it working on their droplet at Digital Ocean. Thanks
    ddyer0
    @ddyer0
    Kudos to whomever can tell me what's wrong with my first test. https://boardspace.net/cheerpj/speed.html
    the html console says Error: Could not find or load main class Speed
    ddyer0
    @ddyer0
    Ok I found it - for the next guy - the /app/ in the example is a literal
    Bruno Eberhard
    @BrunoEberhard
    Hi all. Any news on the support for Java 11 or 17?
    Alessandro Pignotti
    @alexp-sssup
    @BrunoEberhard Support for Java > 8 is in the pipeline but not currently supported. If you have a commercial use case get in touch at sales@leaningtech.com, we might be able to accelerate the project for your use case.
    hgalioulline
    @hgalioulline

    Hey everyone! We are trying to fix a bug with the CheerpJ Java Fiddle but can't figure it out. The bug is sometimes difficult to reproduce, but basically if you play around with the code and click the "Compile and Run" button a few times in between a bunch of small edits you get something like, "Error: Could not find or load main class javafiddle1.JavaFiddle". Any help would be greatly appreciated!

    Here is the most relevant function (in my opinion) for reference:

    function compileJavaCode() {
        var cb = document.getElementById("compileButton");
        cb.disabled = true;
        var console = document.getElementById("console");
        console.textContent = "> Compiling...\r\n\r\n";
        var newCode = editor.getValue();
        var packageName = "javafiddle" + (currentId++).toString();
        newCode = "package " + packageName + ";\n" + newCode;
        cheerpjAddStringFile("/str/JavaFiddle.java", newCode);
        cheerpjRunMain("com.sun.tools.javac.Main", "/app/tools.jar:/files/", "/str/JavaFiddle.java", "-d", "/files/").then(
          function (r) {
            var cb = document.getElementById("compileButton");
            cb.disabled = false;
            // Non-zero exit code means that an error has happened
            if (r == 0) {
              console.textContent = "> Running...\r\n\r\n";
              cheerpjRunMain(packageName + ".JavaFiddle", "/app/tools.jar:/files/");
            }
          }
        );
      }
    hgalioulline
    @hgalioulline
    Forgot to mention it's important to refresh the page in between your edits to the code to reproduce the bug
    Alessandro Pignotti
    @alexp-sssup
    @hgalioulline We believe this problem is already fixed. Javafiddle has been updated from CheerpJ 2.2 -> to the release candidate for CheerpJ 2.3. Please wipe out your browser cache and try again
    hgalioulline
    @hgalioulline

    Thanks! Did this update happen in the last couple of days? On Sunday I was still getting the bug, and now it seems to work :D

    Also surprising because the last update on the Github repo was about a month ago and it was documentation related. Any insight as to where I can check out the update would be great.

    hgalioulline
    @hgalioulline
    Ah okay never mind, I can see now it's the loader.js you changed whose development I assume isn't public.
    hgalioulline
    @hgalioulline

    Hello again! We've been trying to get a minimal demo going of running client-side JUnit test cases based off of your Java Fiddle example:

    cheerpjRunMain(
        "com.sun.tools.javac.Main",
        "/app/tools.jar:/files/:/app/junit-platform-console-standalone-1.8.2.jar",
        "-cp",
        "/app/junit-platform-console-standalone-1.8.2.jar",
        "/str/MainTest.java",
        "/str/Main.java",
        "-d",
        "/files/"
    ).then((r) => {
        // Non-zero exit code means that an error has happened
        if (r == 0) {
            console.textContent = "> Running...\r\n\r\n";
            cheerpjRunMain(
                "org.junit.platform.console.ConsoleLauncher",
                "/app/junit-platform-console-standalone-1.8.2.jar",
                "--classpath",
                "/files/",
                "-c",
                packageName + ".MainTest"
            );
        }
    });

    Unfortunately, we get the following error when trying to run the above:

    Uncaught ReferenceError: _c4pbMlaRcSd52fs20UnixNativeDispatcher7access0E61 is not defined
        at _c4pbMlaRcSZ42fs20UnixNativeDispatcher6accessE60 (rt.jar.sun.nio.js:493:18875)
        at N3sun3nio2fs23LinuxFileSystemProvider._c4pbMlaRcSd12fs22UnixFileSystemPh0LanpWVllOOjiqij5vVd [as v33] (rt.jar.sun.nio.js:475:15446)
        at _h4VaSkWovJxGSqK_HSqiPtCHinj5HNd (rt.jar.java.nio.file.js:210:21411)
        at _c4pbAiq2cqUaClWxcyp0tform7console7opeWZZs18CommandLineOgnHRcyp1mbda$getExistingAddieWJagwn3cGK0dW0HxZuecHKpTNon (junit-platform-conso…2.jar.js:4006:10036)
        at N11CRCb1a82252._c4Vanln3kxqnaVTDUn$eH0Kxn (eval at _c4pbMBWAF72ibuqytpquG0qO140GX4qjXTaij5TJd (VM106808 rt.jar.js:1886:19247), <anonymous>:1:488)
        at N4java4util6stream21ReferencePipeline$2$1._i4pbNkWlcaVakhoJD9krbrerJarkYdXcsdHVTFToGGaXZKNn (rt.jar.java.util.stream.js:1329:436)
        at N4java4util30ArrayList$ArrayListSpliterator._i4pbN6PYArrayList$jLq2Spliterator16forEachRemaieGSWE4 (rt.jar.java.util.js:596:2455)
        at N4java4util6stream19ReferencePipeline$2._i4pbNkWlcaVak_ntTUwG0ueGWukYdXcsdbVGZdMyZKJx9o [as v15] (rt.jar.java.util.stream.js:1444:10534)
        at N4java4util6stream19ReferencePipeline$2._i4pbNkWlcaVakFotTUwG0ueGWukYdXcsdrDUveWJwZaNZdMyZKJxTo [as v14] (rt.jar.java.util.stream.js:1444:9959)
        at N4java4util6stream11ReduceOps$3._i4pbNkWlcaVak3mtn_kXaLab6JKpsji0eutubSqbmrWsarr0mHaS4Dd (rt.jar.java.util.stream.js:1347:376)
    _c4pbMlaRcSZ42fs20UnixNativeDispatcher6accessE60    @    rt.jar.sun.nio.js:493
    _c4pbMlaRcSd12fs22UnixFileSystemPh0LanpWVllOOjiqij5vVd    @    rt.jar.sun.nio.js:475
    _h4VaSkWovJxGSqK_HSqiPtCHinj5HNd    @    rt.jar.java.nio.file.js:210
    _c4pbAiq2cqUaClWxcyp0tform7console7opeWZZs18CommandLineOgnHRcyp1mbda$getExistingAddieWJagwn3cGK0dW0HxZuecHKpTNon    @    junit-platform-conso…e-1.8.2.jar.js:4006
    _c4Vanln3kxqnaVTDUn$eH0Kxn    @    VM107463:1
    _i4pbNkWlcaVakhoJD9krbrerJarkYdXcsdHVTFToGGaXZKNn    @    rt.jar.java.util.stream.js:1329
    _i4pbN6PYArrayList$jLq2Spliterator16forEachRemaieGSWE4    @    rt.jar.java.util.js:596
    _i4pbNkWlcaVak_ntTUwG0ueGWukYdXcsdbVGZdMyZKJx9o    @    rt.jar.java.util.stream.js:1444
    _i4pbNkWlcaVakFotTUwG0ueGWukYdXcsdrDUveWJwZaNZdMyZKJxTo    @    rt.jar.java.util.stream.js:1444
    _i4pbNkWlcaVak3mtn_kXaLab6JKpsji0eutubSqbmrWsarr0mHaS4Dd    @    rt.jar.java.util.stream.js:1347
    _i4pbNkWlcaVak7ntTUwG0ueGWukYdXcsdbprfWcfWeH3n    @    rt.jar.java.util.stream.js:1444
    _i4pbNkWlcaVakJnt9$krbrerJarkYdXcsdXUGZcbinS3np    @    rt.jar.java.util.stream.js:1227
    eval    @    VM107467:3
    runContinuationStack    @    VM106803 loader.js:491
    cheerpjSchedule    @    VM106803 loader.js:1271
    For a little bit of extra info, we used the cheerpjfy Python script to create a JavaScript version of the JUnit standalone launcher and did see a few fallbacks onto legacy code generation. Also, to keep it as simple as possible, Main.java is a basic hello world program and MainTest.java looks like this:
    import java.io.ByteArrayOutputStream;
    import java.io.PrintStream;
    import org.junit.jupiter.api.Assertions;
    import org.junit.jupiter.api.Test;
    public class MainTest {
        private final ByteArrayOutputStream outContent = new ByteArrayOutputStream();
        private final PrintStream originalOut = System.out;
    
        @Test
        public void testOutput() {
            System.setOut(new PrintStream(outContent));
            Main.main(new String[0]);
            Assertions.assertEquals("Hello World!", outContent.toString());
            System.setOut(originalOut);
        }
    }
    Alessandro Pignotti
    @alexp-sssup
    @hgalioulline The problem is already fixed in CheerpJ 2.3
    hgalioulline
    @hgalioulline
    Thanks! Now we're getting:
    No TestIdentifier with unique ID [[engine:junit-jupiter]/[class:javafiddle0.MainTest]] has been added to this TestPlan.
    Alessandro Pignotti
    @alexp-sssup
    @hgalioulline That messages is not generated by the CheerpJ runtime, but by one of the java libraries or framework you are using. Please make sure the program actually works with native java.
    hgalioulline
    @hgalioulline
    Thank you for your quick response! Unfortunately it seems like this error only happens with Cheerpj, I've replicated it with no issues using native java with the two commands:
    javac -cp app/junit-platform-console-standalone-1.8.2.jar str/MainTest.java str/Main.java -d files
    java -jar app/junit-platform-console-standalone-1.8.2.jar --classpath files -c javafiddle0.MainTest
    hgalioulline
    @hgalioulline
    I've also tried using cheerpjRunJar("/app/junit-platform-console-standalone-1.8.2.jar", "-cp", "/files/", "-c", packageName + ".MainTest"); but get the same TestIdentifier error
    Here is the entire stack trace from the JUnit console launcher when run using Cheerpj:
    Failures (1):
      JUnit Jupiter
        => org.junit.platform.commons.PreconditionViolationException: No TestIdentifier with unique ID [[engine:junit-jupiter]/[class:javafiddle0.MainTest]] has been added to this TestPlan.
           org.junit.platform.commons.util.Preconditions.condition(Unknown Source)
           org.junit.platform.launcher.TestPlan.getTestIdentifier(Unknown Source)
           org.junit.platform.launcher.core.ExecutionListenerAdapter.executionStarted(Unknown Source)
           org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(Unknown Source)
           org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(Unknown Source)
           CRCe7c57066.accept(Unknown Source)
           java.util.ArrayList.forEach(Unknown Source)
           org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(Unknown Source)
           org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(Unknown Source)
           CRCb9b7a5c8.execute(Unknown Source)
           [...]
    
    Test run finished after 481 ms
    [         2 containers found      ]
    [         0 containers skipped    ]
    [         2 containers started    ]
    [         0 containers aborted    ]
    [         1 containers successful ]
    [         1 containers failed     ]
    [         0 tests found           ]
    [         0 tests skipped         ]
    [         0 tests started         ]
    [         0 tests aborted         ]
    [         0 tests successful      ]
    [         0 tests failed          ]
    Compared to running natively:
    Test run finished after 58 ms
    [         3 containers found      ]
    [         0 containers skipped    ]
    [         3 containers started    ]
    [         0 containers aborted    ]
    [         3 containers successful ]
    [         0 containers failed     ]
    [         1 tests found           ]
    [         0 tests skipped         ]
    [         1 tests started         ]
    [         0 tests aborted         ]
    [         1 tests successful      ]
    [         0 tests failed          ]
    hgalioulline
    @hgalioulline
    Seems like there is a container it can't find. I have no idea but maybe the Cheerpj directory structure is a little different?
    Alessandro Pignotti
    @alexp-sssup
    @hgalioulline Please give us a link to a fully reproducible example that shows the problem. There is nothing obviously wrong.
    16 replies
    ibelieveczr
    @10142904
    Hi, I succeeded in converting the java program to javascript, but there are some errors in running it
    ·loader.js:503 Uncaught Error: this should be unreachable
    at jnaBA (jni.js:formatted:146642:11)
    at 00486b1a:0xcaf9e
    at _Java_sun_font_SunLayoutEngine_nativeLayout (jni.js:formatted:110773:21)
    at _c4pbM7nEHtZuDolvtjaMd1KxJbsdrTDdWesfXrtemp (rt.jar.sun.font.js:518:2045)
    at N3sun4font15SunLayoutEngine._c4pbMJnEHtZuDolvtjaMd1KxJbsdH$Irme8o (rt.jar.sun.font.js:523:5041)
    at N3sun4font24GlyphLayout$EngineRecord._c4pbMhoEHtZKno4c2ZrjaMd1KVxJbsdXkHGt0G$srtiSNn [as v12] (rt.jar.sun.font.js:402:2019)
    at N3sun4font11GlyphLayout._c4pbMtnEHtZuDn4c2ZrjaMd1K$srgiSNn [as v11] (rt.jar.sun.font.js:72:4970)
    at N3sun4font23ExtendedTextSourceLabel._c4pbMtnEHtZK9T31erZaXqlX1eBbsfDjqaXcVqebWeb4RNDn [as v49] (rt.jar.sun.font.js:730:9201)
    at _c4pbMtnEHtZK9T31erZaXqlX1eBbs5CjqaXsUbXe4RNnn (rt.jar.sun.font.js:730:8641)
    at N3sun4font23ExtendedTextSourceLabel._c4pbMtnEHtZK9T31erZaXqlX1eBbs1DjqaXsDVqebWerPJbIaWYMdvZGKxTo [as v45] (rt.jar.sun.font.js:730:5923)·
    Alessandro Pignotti
    @alexp-sssup
    @10142904 Please make sure to be using CheerpJ 2.3, this error might already be fixed. If not, please publish a minimal reproducible example on a publicly accessible URL
    5 replies
    Alessandro Pignotti
    @alexp-sssup
    @10142904 Apologies for taking a while to reply, we are extremely busy with commercial projects at this time. I have downloaded the archive and the application starts correctly. Can you describe the exact procedure to reproduce the bug?
    36 replies
    ibelieveczr
    @10142904
    image.png
    image.png
    drwangelette
    @drwangelette
    hello. can you point me to some videos of how to get started from the beginnning point of downloading the zip to creating my first conversion of an applet to html5 please
    Carlo Piovesan
    @carlopi
    Hi!
    There are no video guide available, to get started I would recommend taking a look here: https://docs.leaningtech.com/cheerpj/Getting-Started, taking a Java 8 project you know, integrating it in a simple HTML file, and see it load with CheerpJ. Once the basics are in place, next comes AOT compilation via the cheerpjfy script and iterations of the HTML integration.
    Cameron Weibel
    @cameronweibel
    Hi @alexp-sssup, is there a way to directly access the output of cheerpjRunMain() without accessing interacting through the console as is done in https://javafiddle.leaningtech.com/? Ideally we would have something like let codeOutput = await cheerpjRunMain(...);
    Alessandro Pignotti
    @alexp-sssup
    No, the output is send by Java code to the stdout / stderr. CheerpJ runs code as native would.
    There might be Java side solutions to achieve what you want, but it's outside the scope of CJ itself
    PneuC
    @PneuC

    Hi.
    I'm testing a executable jar which uses *javax.imageio.ImageIO" to read image files. When I deploy it on the web, it failed to display any graphics. And I find command line logs like this:

    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] code 404, message File not found
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] "HEAD /META-INF/services/javax.imageio.spi.ImageOutputStreamSpi HTTP/1.1" 404 -
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] code 404, message File not found
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] "HEAD /META-INF/services/javax.imageio.spi.ImageReaderSpi HTTP/1.1" 404 -
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] code 404, message File not found
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] "HEAD /META-INF/services/javax.imageio.spi.ImageWriterSpi HTTP/1.1" 404 -
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] code 404, message File not found
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] "HEAD /META-INF/services/javax.imageio.spi.ImageTranscoderSpi HTTP/1.1" 404 -
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] code 404, message File not found
    ::ffff:127.0.0.1 - - [13/Jul/2022 12:55:06] "HEAD /META-INF/services/javax.imageio.spi.ImageInputStreamSpi HTTP/1.1" 404 -

    Does it means javax.imageio.ImageIO is not supported? How can I fix the problem? I'm using Java 8 and CheerpJ 2.3

    Alessandro Pignotti
    @alexp-sssup
    @PneuC ImageIO is supported. Can you deploy a publicly accessible minimal example so that we can take a look?
    3 replies
    Jeff Martin
    @reportmill
    When are we going to hear news about CheerpJ 3? I keep checking the web site every couple weeks like Christmas is coming. :-)
    hgalioulline
    @hgalioulline
    We were testing our platform for bugs and noticed that Cheerpj doesn't run in a private Firefox tab. We double checked to see if this is also the case for the Java Fiddle (https://javafiddle.leaningtech.com/) and it seems to be a problem there too.
    Alessandro Pignotti
    @alexp-sssup
    @hgalioulline That is a known problem due to the fact that Firefox does not support IndexedDB in private mode. This is unfortunately not easy to workaround, since IndexedDB is the only writable storage CJ supports and Java does need some form of writable storage to work. Since Firefox has (unfortunately) a small user base, and Private even more so, we cannot allocate work to fix the problem outside of a project.
    David Greene
    @David-Greene-Imprivata
    It's my understanding that TCP-based communication isn't possible in WebAssembly (in the browser). Is this also true for cheerpj? I tried taking a Swing-based SSH client and porting with the cheerpjfy.py script. It looked great until the "connect" portion. I assume this was the issue, but I wanted to be clear before dismissing this as a solution.
    Yuri Iozzelli
    @yuri91
    Hi @David-Greene-Imprivata ! What you say is true: there is no way to have arbitrary tcp/udp connections from a browser. Any solution would require some sort of relay server. Cheerpj thus doesn't support this out of the box. We have custom solutions for customers, and we are also working on a more general solution that may be released to the public at some point in the future
    David Greene
    @David-Greene-Imprivata
    Thanks for following up!
    FFFFQQQQ
    @ffffqqqq:matrix.org
    [m]
    I am involved in the need to share Java source code or packaged jar ?
    1 reply
    povaloh830
    @povaloh830:matrix.org
    [m]

    Hello,
    Should I expect, that I can compile pretty much all jar to js, using CheerpJ?

    Today I decided to try this solution. I created a simple app with lucene-core:9.3.0. When I compile my jar, I see the following log:

    ~/cheerpj_2.3$ python3 ./cheerpjfy.py /mnt/c/Users/povaloh830/IdeaProjects/Test-Java11/build/libs/Test-Java11-1.0-SNAPSHOT.jar
    Compiling jar  /mnt/c/Users/povaloh830/IdeaProjects/Test-Java11/build/libs/Test-Java11-1.0-SNAPSHOT.jar
    compiling Main.class ...
    Failure compiling Main.class
    command: /home/povaloh830/cheerpj_2.3/bin/cheerpj -llvm -llvm-exceptions -cp /tmp/tmp_sadxwot/rt.jar.dir/ Main.class
    
    Using legacy codegen for Main.class

    But in the end I get my js file. Than I use html page from https://docs.leaningtech.com/cheerpj/Tutorial and try to run it. I get the following log:

    CheerpJ is initializing
    CheerpJ runtime ready
    
    Unhandled exception N4java4lang20NullPointerException / loader.js:2403:12
    Uncaught (in promise) org/apache/lucene/analysis/standard/StandardAnalyzer loader.js:551:28

    Of course, I can run this program, when I use regular JVM.

    The code of program:

    import org.apache.lucene.analysis.standard.StandardAnalyzer;
    import org.apache.lucene.document.Document;
    import org.apache.lucene.document.Field;
    import org.apache.lucene.document.TextField;
    import org.apache.lucene.index.DirectoryReader;
    import org.apache.lucene.index.IndexReader;
    import org.apache.lucene.index.IndexWriter;
    import org.apache.lucene.index.IndexWriterConfig;
    import org.apache.lucene.queryparser.classic.ParseException;
    import org.apache.lucene.queryparser.classic.QueryParser;
    import org.apache.lucene.search.IndexSearcher;
    import org.apache.lucene.search.Query;
    import org.apache.lucene.search.ScoreDoc;
    import org.apache.lucene.search.TopDocs;
    import org.apache.lucene.store.ByteBuffersDirectory;
    import org.apache.lucene.store.Directory;
    
    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;
    
    public class Main {
    
    
        static StandardAnalyzer analyzer = new StandardAnalyzer();
        static Directory memoryIndex = new ByteBuffersDirectory();
    
        public static List<Document> searchIndex(String inField, String queryString) throws ParseException, IOException {
            Query query = new QueryParser(inField, analyzer)
                    .parse(queryString);
    
            IndexReader indexReader = DirectoryReader.open(memoryIndex);
            IndexSearcher searcher = new IndexSearcher(indexReader);
            TopDocs topDocs = searcher.search(query, 10);
            List<Document> documents = new ArrayList<>();
            for (ScoreDoc scoreDoc : topDocs.scoreDocs) {
                documents.add(searcher.doc(scoreDoc.doc));
            }
    
            return documents;
        }
    
        public static void main(String[] args) throws IOException, ParseException {
            IndexWriterConfig indexWriterConfig = new IndexWriterConfig(analyzer);
            IndexWriter writter = new IndexWriter(memoryIndex, indexWriterConfig);
            Document document = new Document();
    
            document.add(new TextField("title", "title", Field.Store.YES));
            document.add(new TextField("body", "bodyefw", Field.Store.YES));
    
            writter.addDocument(document);
            writter.close();
    
            List<Document> documents = searchIndex("title", "title");
    
            System.out.println(documents.get(0).get("body"));
        }
    }

    P.S. I also tried to run hello world app, and it works fine.

    2 replies
    povaloh830
    @povaloh830:matrix.org
    [m]
    So, I've tried to build the same program with JDK 8. To do it, I had to downgrade lucene-core from 9.3.0 to 8.11.2. After this change, I've managed to run my program with regular JVM. However, I am still getting the same error, when run it from browser (loader.js:551 Uncaught (in promise) org/apache/lucene/analysis/standard/StandardAnalyzer)
    4 replies
    povaloh830
    @povaloh830:matrix.org
    [m]

    Well, I did a few steps:

    1. Compiled libraries:
    for f in lucene-queries-8.11.2.jar lucene-sandbox-8.11.2.jar lucene-core-8.11.2.jar lucene-queryparser-8.11.2.jar
    do
        ~/cheerpj_2.3/cheerpjfy.py --deps lucene-queries-8.11.2.jar:lucene-sandbox-8.11.2.jar:lucene-core-8.11.2.jar:lucene-queryparser-8.11.2.jar $f
    done
    1. Compiled a main jar:
    python3 ~/cheerpj_2.3/cheerpjfy.py --deps /mnt/c/Users/povaloh830/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-queryparser/8.11.2/1886e3a27a8d4a73eb8fad54ea93a160b099bc60/lucene-queryparser-8.11.2.jar:/mnt/c/Users/povaloh830/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-core/8.11.2/57438c3f31e0e440de149294890eee88e030ea6d/lucene-core-8.11.2.jar:/mnt/c/Users/povaloh830/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-queries/8.11.2/c86c8bbd6dddfb6870fc2f59989cb89d50290d5a/lucene-queries-8.11.2.jar:/mnt/c/Users/povaloh830/.gradle/caches/modules-2/files-2.1/org.apache.lucene/lucene-sandbox/8.11.2/5ff823b4a429ccf842386a008b08bddfa88d9f87/lucene-sandbox-8.11.2.jar /mnt/c/Users/povaloh830/IdeaProjects/Test-Java11/build/libs/Test-Java11-1.0-SNAPSHOT.jar
    1. Fixed html:
    cheerpjRunMain("Main", "/app/Test-Java11-1.0-SNAPSHOT.jar:/app/lucene-queries-8.11.2.jar:/app/lucene-sandbox-8.11.2.jar:/app/lucene-core-8.11.2.jar:/app/lucene-queryparser-8.11.2.jar");
    $ ls *.js
    Test-Java11-1.0-SNAPSHOT.jar.js  lucene-queries-8.11.2.jar.js      lucene-sandbox-8.11.2.jar.js
    lucene-core-8.11.2.jar.js        lucene-queryparser-8.11.2.jar.js

    Now I get one more line of logs, but at the end of story I am still getting errror, another one:

    CheerpJ is initializing
    CheerpJ runtime ready
    Run main for Main <-- new one
    loader.js:2447 Uncaught (in promise)
    2 replies
    povaloh830
    @povaloh830:matrix.org
    [m]

    sorry for name of project, I switched to jdk8, but didn't change names.

    lib jars:

    1. https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/8.11.2/lucene-core-8.11.2.jar
    2. https://repo1.maven.org/maven2/org/apache/lucene/lucene-queries/8.11.2/lucene-queries-8.11.2.jar
    3. https://repo1.maven.org/maven2/org/apache/lucene/lucene-queryparser/8.11.2/lucene-queryparser-8.11.2.jar
    4. https://repo1.maven.org/maven2/org/apache/lucene/lucene-sandbox/8.11.2/lucene-sandbox-8.11.2.jar

    app:

    1. attachment

    html:

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <title>CheerpJ test</title>
        <script src="https://cjrtnc.leaningtech.com/2.3/loader.js"></script>
    </head>
    <body>
    </body>
    <script>
          cheerpjInit();
          cheerpjRunMain("Main", "/app/Test-Java11-1.0-SNAPSHOT.jar:/app/lucene-queries-8.11.2.jar:/app/lucene-sandbox-8.11.2.jar:/app/lucene-core-8.11.2.jar:/app/lucene-queryparser-8.11.2.jar");
    
      </script>
    </html>
    4 replies
    Cameron Weibel
    @cameronweibel
    We have an issue where we can warm start CheerpJ using the method below just fine with one tab open, but if we have a second tab open, the final cheerpjRunMain promise never resolves. Any idea why this method hangs when a second tab is open?
      async cheerpJWarmStartTests({ commit, state }) {
        console.info("warm starting tests");
        // Store console logs in a global buffer called console.logs
        if (state.cheerpJ.warmStarted) {
          console.info("already started");
          return;
        }
        console.stdlog = console.log.bind(console);
        console.logs = [];
        console.log = function () {
          let args = Array.from(arguments);
          // OPTIONAL: Filtering on which messages are stored in console.logs
          // if (String(args[0]).includes("WARM")) {
          //   console.logs.push(args);
          // }
          console.logs.push(args);
          console.stdlog.apply(console, arguments);
        };
        commit("INCREMENT_CHEERPJ_PACKAGE_ID");
        var packageName = "javafiddle" + state.cheerpJ.packageId.toString();
        cheerpjAddStringFile(
          "/str/Main.java",
          "package " +
            packageName +
            '; public class Main {public static void main(String[] args) {System.out.print("Hello World!");}}'
        );
        cheerpjAddStringFile(
          "/str/MainTest.java",
          "package " +
            packageName +
            '; \
        import java.io.ByteArrayOutputStream; \
        import java.io.PrintStream; \
        import org.junit.jupiter.api.Assertions; \
        import org.junit.jupiter.api.Test; \
        import org.junit.jupiter.api.AfterEach; \
        public class MainTest { \
          private final ByteArrayOutputStream outContent = new ByteArrayOutputStream(); \
          private final PrintStream originalOut = System.out; \
          @Test public void testOutput() { \
            System.setOut(new PrintStream(outContent)); \
            Main.main(new String[0]); \
            Assertions.assertEquals("Hello World!", outContent.toString()); \
          } \
          @AfterEach \
          public void tearDown() { \
            System.setOut(originalOut); \
          } \
        }'
        );
        console.logs.length = 0;
        cheerpjRunMain(
          "com.sun.tools.javac.Main",
          "/app/tools.jar:/files/:/app/junit-platform-console-standalone-1.8.2.jar",
          "-cp",
          "/app/junit-platform-console-standalone-1.8.2.jar",
          "/str/MainTest.java",
          "/str/Main.java",
          "-d",
          "/files/"
        )
          .then((r) => {
            console.info("THEN");
            console.info(r);
            // Non-zero exit code means that an error has happened
            if (r == 0) {
              cheerpjRunMain(
                "org.junit.platform.console.ConsoleLauncher",
                "/app/junit-platform-console-standalone-1.8.2.jar",
                "--classpath",
                "/files/",
                "-c",
                packageName + ".MainTest"
              ).then(() => {
                commit("SET_CHEERPJ_WARM_STARTED");
                console.logs.length = 0;
              });
            }
          })
          .catch((r) => {
            console.info("CATCH");
            console.info(r);
          })
          .finally(() => {
            console.info("FINALLY");
          });
      }
    Alessandro Pignotti
    @alexp-sssup
    @cameronweibel Can you provide a link to a deployed fully reproducible example? There were, in the past, some issues causing code not to be run when a tab is not visible, but such issues should be all fixed.
    Please notice that CheerpJ support is being migrated to Discord: https://discord.leaningtech.com