CheerpJ can't get my game onto a site
Hello, I tried to put my Java game (which is a jar file) into cheerpJ, and this is my code:
This is the structure of my project:
However, this is the output I got when I ran my game (shown in the images attached) - what problem am I facing? Thanks so much for your help!
61 Replies
Misunderstanding of the virtual file structure I think. /app/TextDemo.jar is actually just localhost:8080/TextDemo.jar
Move the jar to the root beside index.html
Leaning Technologies Developer
Files and filesystems - CheerpJ Documentation
Virtual filesystems and how to use them
This is my new structure but I still got the same problem (also I got the wrong screenshot earlier)
The full error message is this:
Thanks for the help again!
Perhaps try
/app/web/PlatformGameProject.jar
as the path?I tried
didn't work sorry
I think the deprecation warning is causing this problem
are you using the http-server package from npm? if so, the deprecation warning is normal and has always been there
it has no effect
could you send me the command you're using to start http-server?
and in what directory you're running it in?
Here is what it looks like when I run the command - should I use an alternate command to run the program?
Once again thanks for the help!
not really sure then, sorry :(
have you tried refreshing the page with shift+f5?
just to see if the error is cached or something
I should clear cache right
Didn't work
I tried downgrading but I got new errors
I tried using python as an alternative
But it still didn't work
From the information you provided it seems to me quite clear that the path should be
/app/web/PlatformGameProject.jar
. But I think there is some misunderstanding about the directory the server is running from.
Can the browser find your jar if you visit http://127.0.0.1:8080/web/PlatformGameProject.jar
I can 100% confirm that has nothing to do with either using python or node (or anything else) as HTTP servers, this is just a directory problem.
To add more context, I suspect that the web
directory is simply not in the same directory as your webserver. Can you list files from the terminal view to make sure?I tried using the suggested path but it still doesn't seem to work
Can you confirm if
http://127.0.0.1:8080/web/PlatformGameProject.jar
works?
Used directly as an address in your browserIt just downloads the jar file
The
cheerpjRunJar("/app/web/PlatformGameProject.jar")
is 100% correct
Please open the devtools console to see what is the actual error message
You should also notice that the web server logs do not return 404 anymoreHere's my newest attempt (I tried using the python command in the web)
There is some confusion here. What happens if you visit
http://127.0.0.1:8000/web/PlatformGameProject.jar
It is simply not possible that the same request works when using directly from the browser, but returns 404 via CheerpJThe jar file gets downloaded
Please share a screenshot of the server logs
Yes, as you have done just now
I see
Fyi
I can't get it to work with the TextDemo.jar file on the cheerpj site as well
You're running the server from the wrong directory here.
Make sure your current working directory is
C:\Users\alfee\PlatformGameProject
.Don't use cd web right?
Yes
i didn't use cd web and it still doesn't work
I do not see any 404 in the server logs. So if it doesn't work still that's a different issue.
I want to do this in a systematic way, so what command should I run and where?
This was my first try btw
The way you did it without
cd
is fine, please now send a screenshot of browser console and the network tab. Make sure you're not getting any other errors.
I don't know what your app is supposed to do, but at this point the jar file is definitely being loaded by cheerpj. If there's any other issues please tell me what is the expected behaviour and show how it's not working.My app is a platform game that I created
I think it's the wrong location/command but it's not related to the jar file itself since I couldn't run textdemo with this
Here's the error message I received this time
There is no error message there. Those messages are just telling you that it's serving the file correctly.
It has the deprecation warning though
I got the exact same result with the TextDemo.jar file
That's a warning with from http-server, outside of your control, it should still work.
Please share a screenshot of your browser console window and network tab, to see if there's any errors there.
I see
Apparently it only supports Java 8?
Guess it is a jar file problem
Yes, that is correct. Cheerpj only supports Java 8 at this time.
Please note that you might be able to compile your Java code for Java 8
How can I do that?
Currently my jar file runs on the latest version of java, do I have to manually edit the jar file or is there an alternative method?
Anyways thanks @Chen @Alessandro for your help so far!
That depends on your IDE or build system, we cannot provide direct help on this but you'll find plenty of information on the internet
Thanks for this step anyways!
I think I can get it to work on Java 8, just need to remove a few case -> syntax errors
If it doesn't work despite the change I'll let you guys know 🙂
New update
I fixed the java 8 issue but I got this in return 😦
The exception happens since your application is trying to use audio, which is currently not supported in CheerpJ. We are working on this feature right now.
I see ☠️ guess I have to remove the audio related files from my jar file
But thanks so much for the help anyways!
Will cheerpj remain operational for the time being though?
Can you clarify what you mean?
Cheerpj3 won't be deprecated for a long time right?
CheerpJ 3 has been released earlier this year and has long term support
That's a relief to hear!
Update: I could get past the graphics initializing stage but now I get a blank screen
There is no information here that could allow us to debug the problem. I would recommend to make sure the game still work on native. Changes have been introduced to remove the use of sound and it could be that the logic of the game was accidentally broken in the process.
If the game still work on native, please deploy your test to a publicly accessible URL, and we can take a look. We don't need the sourcecode, just the HTML and the jar on a public website that we can access directly.
I checked, and the game works on native
Reminder, if you can upload the whole page to a publicly accessible URL we could take a look, otherwise there is not much we can do to further help you.
Please also try to use a more recent CJ3 nightly build, for example: https://cjrtnc.leaningtech.com/3_20240706_509/cj3loader.js
a
outdated