Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept path to jad / jar from commandline #169

Open
stuaxo opened this issue Jan 17, 2023 · 4 comments
Open

Accept path to jad / jar from commandline #169

stuaxo opened this issue Jan 17, 2023 · 4 comments

Comments

@stuaxo
Copy link

stuaxo commented Jan 17, 2023

If the user passes the jar a path to a jad or jar it should be loaded.

Currently invoking like this causes an exception [1]

(I tried prepending file:// to the URI but then I get 'Error: Unable to access jarfile freej2me.jar)

$ java -jar freej2me.jar /home/stu/Desktop/ogdisk/dev/work/galaxylife/gl-game/clients/mobile/trunk/lib/mobile3d.jar

no protocol: /home/stu/Desktop/ogdisk/dev/work/fp/GhostDetector/jars/ns40128128.0.jad
java.net.MalformedURLException: no protocol: /home/stu/Desktop/ogdisk/dev/work/fp/GhostDetector/jars/ns40128128.0.jad
	at java.base/java.net.URL.<init>(URL.java:645)
	at java.base/java.net.URL.<init>(URL.java:541)
	at java.base/java.net.URL.<init>(URL.java:488)
	at org.recompile.mobile.MobilePlatform.loadJar(MobilePlatform.java:157)
	at org.recompile.freej2me.FreeJ2ME.<init>(FreeJ2ME.java:249)
	at org.recompile.freej2me.FreeJ2ME.main(FreeJ2ME.java:36)
Couldn't load jar...
^C%                       
@recompileorg
Copy link
Collaborator

.jad files are completely unnecessary, which is why they're not supported.

@stuaxo
Copy link
Author

stuaxo commented Jan 17, 2023

That's fair enough - it's fairly usual to have them both in a folder next to each other (especially if compiling code), I was thinking it would just open the jar next to it (better would be to check the jad).

Alternately displaying a message that you need to open the jar would be good - it's pretty easy with tab completion to end up pointing this at a jad.

@AShiningRay
Copy link
Contributor

That's fair enough - it's fairly usual to have them both in a folder next to each other (especially if compiling code), I was thinking it would just open the jar next to it (better would be to check the jad).

Alternately displaying a message that you need to open the jar would be good - it's pretty easy with tab completion to end up pointing this at a jad.

Processing the input string to swap any .jad extension for .jar would be a way of "solving" that kind of issue, though it might mislead the user by making them think that the jad file is actually being opened. The simplest way of dealing with that one, in turn, would be adding a println statement in the console whenever a jad file is received as input... but then FreeJ2ME needs to be opened with the console for the user to read that.

Using window prompts is the most intuitive, but might also end up in a situation of killing an ant with a sledgehammer since that's not used for anything in FJ2ME so a few more classes would have to be included just for that, which might cause issues with sdl2 and libretro if someone were to open a jad on those versions.

I can make this into a PR, but i'd rather wait for @recompileorg 's opinion on that as it can certainly lead to misunderstandings pertaining to jad and jar file support.

@stuaxo
Copy link
Author

stuaxo commented Feb 1, 2023

Ah - I think the real issue I had was I was passing a file path, not a URI "file:///path/to/midlet.jar"

It would be good, if the path passed in is not a URL, but does point to a jar/jad, it would be good if the conversion to file: URI could happen internally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants