Trying to get CheerpJ to actually launch a program
I'm trying to get CheerpJ to run UPRandomizer in a browser, but I can't figure out how to get it to start. It always gives the error "Error: Could not find or load main class com.dabomstew.pkrandom.gui.RandomizerGUI"
Can anyone help me with this?
22 Replies
Most likely the classpath used for the
cheerpjRunMain
API call is not correct. I would recommend to follow the Tutorial once to get a better understanding of the tool: https://labs.leaningtech.com/cheerpj2/getting-started/TutorialInstallation
Run C/C++, Java, and native code in the browser with our WebAssembly developer tools and JavaScript libraries: Cheerp, CheerpJ, and CheerpX
That's uh
That's what I did
Does the tutorial application work for you?
Nope
Then there must be some obvious mistake in the page integration. Do you get any error on the dev tools console?
I am referring to the tutorial application right now, it's quite likely that by debugging that we can understand what the problem is in your own app
wait so just using the tutorial html will result in a separate app being run?
I'm might stupid
The tutorial HTML is intended to run the specific JAR file referenced in the tutorial itself. This happens via the
cheerpjRunJar
API
Please try the whole tutorial from start to finish, so that you can get a better understanding of the tool.
If your application is normally started via java -jar <name>.jar
then the cheerpjRunJar
API is the correct one
If, on the other hand, the app is normally started via java -cp <jar1.jar>:<jar2.jar> name.of.main.Class
, you need to use the cheerpjRunMain
API
But the rest of the HTML stays the sameI'm gonna work on this tomorrow
okay I got it to work
Though now I need to figure out how to have it save files to my computer if possible
You will need to write some integration manually in JavaScript, the browsers are very limited in the access they provide for the filesystem so CheerpJ works with a completely virtualized file system
For more info about filesystems please see: https://labs.leaningtech.com/cheerpj2/guides/File-System-support
File System support
Run C/C++, Java, and native code in the browser with our WebAssembly developer tools and JavaScript libraries: Cheerp, CheerpJ, and CheerpX
You will need to save the file on the read-write
/files/
mount pointIt already is able to save to /files/
I just don't know how to get it from there onto my computer
You can get a Blob object using the
cjFileBlob
API, for example cjFileBlob("/files/file1.txt")
It returns a promise that resolve to a Blob
you can then download it using standard JS techniquesI'm sure that's helpful, though I don't know nearly any JS
I do appreciate it
Something along this line should work: https://stackoverflow.com/questions/25547475/save-to-local-file-from-blob
Stack Overflow
Save to Local File from Blob
I have a difficult question to you, which i'm struggling on for some time now.
I'm looking for a solution, where i can save a file to the users computer, without the local storage, because local st...
Being a standard technique you might be able to even find examples more similar to what you want to achieve precisely.
The keywords are "Blob" and "download"
in the context of JavaScript, of course
👍
Thanks, man
I am marking this thread as resolved, for further general questions consider using the #cheerpj2 channel
okiecoke
One last thing, could you elaborate what part of the tutorial was not clear in the beginning? We are in the process or revisiting the docs and your input might be useful in that regard
I was skimming through it while very tired, so I couldn't tell you
Ok, thanks for your feedback nonetheless. Take care.