Support / Discussion for CheerpJ has been migrated to Discord https://discord.leaningtech.com
thanks this loader works.. but when I use DOM with worker i got this error in browser console
Uncaught (in promise) com/leaningtech/client/JSString
this is the java method source
Document d = Global.document;
JSString str = Global.JSString("existingNode");
Element e = d.createElement(str);
e.set_textContent(Global.JSString("Worker 1 Method 1 result"));
Element newDiv = Global.document.createElement(Global.JSString("p"));
newDiv.set_textContent(e.get_textContent().substring(2).toUpperCase());
Global.document.get_body().appendChild(newDiv);
JSString divContent = newDiv.get_textContent();
Global.console.log(divContent);
loader.js:2973 CheerpJ is initializing
loader.js:3691 [Violation] 'message' handler took 250ms
loader.js:235 [Violation] 'load' handler took 267ms
loader.js:3691 [Violation] 'message' handler took 216ms
rt.jar.js:1885 [Violation] 'setTimeout' handler took 226ms
rt.jar.js:1885 [Violation] 'setTimeout' handler took 81ms
loader.js:235 [Violation] 'load' handler took 212ms
[Violation] 'complete' handler took 266ms
rt.jar.js:1885 [Violation] 'setTimeout' handler took 61ms
loader.js:3691 [Violation] 'message' handler took 269ms
rt.jar.js:1885 [Violation] 'setTimeout' handler took 164ms
loader.js:1235 [Violation] 'message' handler took 183ms
cheerpOS.js:1753 11:59:06.216 : Utility.setDebugValue() true
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.225 : VdtAppApplet.init()
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.311 : Utility.getScreenSize() java.awt.Dimension[width=631,height=590] debugValue debugScreenSize 0.75
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.315 : Utility.getScreenSize() java.awt.Dimension[width=631,height=590] debugValue debugScreenSize 0.75
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.319 : GetProperty(): checking for System property os.name
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.321 : GetProperty(): checking for System property os.name
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.338 : VdtAbstractDataModel.constructor() Version 2001-0126 this vdt.accom.AccomDataModel@b7
cheerpOS.js:1753
cheerpOS.js:1753 AccomDataModel constructor *
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.344 : VdtAbstractDataModel.initializeDataModel()
cheerpOS.js:1753
cheerpOS.js:1753 11:59:06.348 : VdtConfig.getConfig() Create singleton VdtConfig object.
cheerpOS.js:1753
cheerpOS.js:1753 java.lang.NoClassDefFoundError: xmlrpc/SimpleXmlRpcClient
cheerpOS.js:1753
The page source:
<!--
#
#
#
#
-->
<html>
<head><title>Gemstone DVT© Training</title></head>
<body bgcolor="black">
<table border=0 cellspacing=0 cellpadding=0 align=center>
<tr><td align=center>
<script language=javascript>
if (self.innerWidth)
{
frameWidth = self.innerWidth;
frameHeight = self.innerHeight;
}
else if (document.body)
{
frameWidth = document.body.clientWidth;
frameHeight = document.body.clientHeight;
}
width = .9 frameWidth;
height = .8 frameHeight;
// Check for decimal point + round down
width = width + '';
if(width.indexOf('.') >= 0) {
width = width.substring(0,width.indexOf('.'));
}
height = height + '';
if(height.indexOf('.') >= 0) {
height = height.substring(0,height.indexOf('.'));
}
document.write('<applet codebase="/lib/" ');
document.write('archive="patch.jar,collections.jar,swing.jar,xmlrpc.jar" ');
document.write('code="vdt.VdtModuleApplet.class" ');
document.write('width="' + width + '"');
document.write('height="' + height + '">');
document.write("\r\n");
</script>
<param name="XMLRPC" value="http://intrepid.gemstonevision.org/xmlrpc">
<param name="MODULE" value="vdt.accom.Accom">
<param name="SESSION_ID" value="99880" >
<param name="NEXT_PAGE" value="http://intrepid.gemstonevision.org/dvt/valley/results.html?nocache=1643572993">
<param name="ERROR_PAGE" value="http://intrepid.gemstonevision.org/dvt/valley/error.html?nocache=1643572993">
<param name="LEVEL" value="1">
<param name="RECOVERY" value="0">
Sorry, this browser cannot run the DVT© software ( Java support required ).
</applet>
</td></tr>
<tr><td align=center>
<table width="100%">
<tr>
<td align="left" width="33%">
<font color="lightskyblue">
ABRAHAM CABIDA
</font>
</td>
<td align="center" width="34%">
<font color="lightskyblue">
<img src="/images/flipper1.gif">
</font>
</td>
<td align="right" width="33%">
<font color="lightskyblue">
Module 1 of 5
</font>
</td>
</tr>
</table>
</td></tr>
</table>
</body>
</html>
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/");
}
}
);
}
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.
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
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);
}
}
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
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 ]
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 ]