freej2me icon indicating copy to clipboard operation
freej2me copied to clipboard

Accept path to jad / jar from commandline

Open stuaxo opened this issue 2 years ago • 4 comments

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%                       

stuaxo avatar Jan 17 '23 20:01 stuaxo

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

recompileorg avatar Jan 17 '23 20:01 recompileorg

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.

stuaxo avatar Jan 17 '23 23:01 stuaxo

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.

AShiningRay avatar Jan 27 '23 18:01 AShiningRay

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.

stuaxo avatar Feb 01 '23 23:02 stuaxo