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:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CheerpJ test</title>
<script src="https://cjrtnc.leaningtech.com/3.0/cj3loader.js"></script>
</head>
<body>
<script>
(async function () {
await cheerpjInit();
cheerpjCreateDisplay(800, 600);
await cheerpjRunJar("/app/PlatformGameProject.jar");
})();
</script>
</body>
</html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title>CheerpJ test</title>
<script src="https://cjrtnc.leaningtech.com/3.0/cj3loader.js"></script>
</head>
<body>
<script>
(async function () {
await cheerpjInit();
cheerpjCreateDisplay(800, 600);
await cheerpjRunJar("/app/PlatformGameProject.jar");
})();
</script>
</body>
</html>
This is the structure of my project:
| index.html
|
\---app
PlatformGameProject.jar
| index.html
|
\---app
PlatformGameProject.jar
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!
No description
No description
61 Replies
downthecrop
downthecrop4mo ago
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
Can eater
Can eater4mo ago
index.html
PlatformGameProject.jar
index.html
PlatformGameProject.jar
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:
[2024-06-30T09:39:24.913Z] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
(node:26184) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
[2024-06-30T09:39:27.830Z] "GET /web/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.697Z] "GET /PlatformGameProject.jar" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.705Z] "GET /PlatformGameProject.jar" Error (404): "Not found"
[2024-06-30T09:43:25.919Z] "GET /PlatformGameProject.jar" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.922Z] "GET /PlatformGameProject.jar" Error (404): "Not found"
[2024-06-30T09:43:25.947Z] "GET /PlatformGameProject.jar" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.952Z] "GET /PlatformGameProject.jar" Error (404): "Not found"
[2024-06-30T09:39:24.913Z] "GET /" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
(node:26184) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
(Use `node --trace-deprecation ...` to show where the warning was created)
[2024-06-30T09:39:27.830Z] "GET /web/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.697Z] "GET /PlatformGameProject.jar" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.705Z] "GET /PlatformGameProject.jar" Error (404): "Not found"
[2024-06-30T09:43:25.919Z] "GET /PlatformGameProject.jar" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.922Z] "GET /PlatformGameProject.jar" Error (404): "Not found"
[2024-06-30T09:43:25.947Z] "GET /PlatformGameProject.jar" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
[2024-06-30T09:43:25.952Z] "GET /PlatformGameProject.jar" Error (404): "Not found"
Thanks for the help again!
Hypex
Hypex4mo ago
Perhaps try /app/web/PlatformGameProject.jar as the path?
Can eater
Can eater4mo ago
I tried didn't work sorry I think the deprecation warning is causing this problem
Hypex
Hypex4mo ago
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?
Can eater
Can eater4mo ago
Here is what it looks like when I run the command - should I use an alternate command to run the program?
No description
Can eater
Can eater4mo ago
Once again thanks for the help!
Hypex
Hypex4mo ago
not really sure then, sorry :( have you tried refreshing the page with shift+f5? just to see if the error is cached or something
Can eater
Can eater4mo ago
I should clear cache right Didn't work I tried downgrading but I got new errors
Can eater
Can eater4mo ago
I tried using python as an alternative
No description
Can eater
Can eater4mo ago
But it still didn't work
apignotti
apignotti4mo ago
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?
Can eater
Can eater4mo ago
I tried using the suggested path but it still doesn't seem to work
apignotti
apignotti4mo ago
Can you confirm if http://127.0.0.1:8080/web/PlatformGameProject.jar works? Used directly as an address in your browser
Can eater
Can eater4mo ago
It just downloads the jar file
apignotti
apignotti4mo ago
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 anymore
Can eater
Can eater4mo ago
Here's my newest attempt (I tried using the python command in the web)
No description
apignotti
apignotti4mo ago
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 CheerpJ
Can eater
Can eater4mo ago
The jar file gets downloaded
apignotti
apignotti4mo ago
Please share a screenshot of the server logs
apignotti
apignotti4mo ago
Yes, as you have done just now
Can eater
Can eater4mo ago
I see
Can eater
Can eater4mo ago
No description
Can eater
Can eater4mo ago
Fyi I can't get it to work with the TextDemo.jar file on the cheerpj site as well
DutChen18
DutChen184mo ago
You're running the server from the wrong directory here. Make sure your current working directory is C:\Users\alfee\PlatformGameProject .
Can eater
Can eater4mo ago
Don't use cd web right?
DutChen18
DutChen184mo ago
Yes
Can eater
Can eater4mo ago
No description
Can eater
Can eater4mo ago
i didn't use cd web and it still doesn't work
DutChen18
DutChen184mo ago
I do not see any 404 in the server logs. So if it doesn't work still that's a different issue.
Can eater
Can eater4mo ago
I want to do this in a systematic way, so what command should I run and where?
Can eater
Can eater4mo ago
This was my first try btw
No description
DutChen18
DutChen184mo ago
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.
Can eater
Can eater4mo ago
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
Can eater
Can eater4mo ago
Here's the error message I received this time
No description
DutChen18
DutChen184mo ago
There is no error message there. Those messages are just telling you that it's serving the file correctly.
Can eater
Can eater4mo ago
It has the deprecation warning though I got the exact same result with the TextDemo.jar file
DutChen18
DutChen184mo ago
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.
Can eater
Can eater4mo ago
I see
Can eater
Can eater4mo ago
Apparently it only supports Java 8?
No description
Can eater
Can eater4mo ago
Guess it is a jar file problem
DutChen18
DutChen184mo ago
Yes, that is correct. Cheerpj only supports Java 8 at this time.
apignotti
apignotti4mo ago
Please note that you might be able to compile your Java code for Java 8
Can eater
Can eater4mo ago
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!
apignotti
apignotti4mo ago
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
Can eater
Can eater4mo ago
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 🙂
Can eater
Can eater4mo ago
New update
No description
Can eater
Can eater4mo ago
I fixed the java 8 issue but I got this in return 😦
apignotti
apignotti4mo ago
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.
Can eater
Can eater4mo ago
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?
apignotti
apignotti4mo ago
Can you clarify what you mean?
Can eater
Can eater4mo ago
Cheerpj3 won't be deprecated for a long time right?
apignotti
apignotti4mo ago
CheerpJ 3 has been released earlier this year and has long term support
Can eater
Can eater4mo ago
That's a relief to hear!
Can eater
Can eater4mo ago
Update: I could get past the graphics initializing stage but now I get a blank screen
No description
apignotti
apignotti4mo ago
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.
Can eater
Can eater4mo ago
I checked, and the game works on native
apignotti
apignotti4mo ago
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
fake hecker
fake hecker2mo ago
a outdated
Want results from more Discord servers?
Add your server