osmandapp / OsmAnd-tools

OsmAnd tools to generate new maps & to test OsmAnd files on PC
osmand.net
Other
97 stars 82 forks source link

Solution to "Could not find or load main class" on Windows #334

Open Bernhard-Hiller opened 5 years ago

Bernhard-Hiller commented 5 years ago

When an osmand tool is started from the Windows command line, but the current working directory is different from the folder that tool is located in, a "Could not find or load main class" exception is thrown from java.

This is caused by an insufficient classpath definition. Please change the call in e.g. inspector.bat to

java.exe -Djava.util.logging.config.file=logging.properties -Xms64M -Xmx512M -cp "%~dp0\OsmAndMapCreator.jar";"%~dp0\lib\*.jar" net.osmand.obf.BinaryInspector %*

and in the other .bat files accordingly.

pyramid3d commented 2 years ago

Not sure this is related but I do get this error:

java.lang.reflect.InaccessibleObjectException: Unable to make private java.util.Collections$EmptyMap() accessible: module java.base does not "opens java.util" to unnamed module @7692d9cc

tried running with the following command (openjdk 17) without change:

java $JAVA_OPTS -Djava.util.logging.config.file="$DIR/logging.properties" -jar "$DIR/OsmAndMapCreator.jar" --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED

EDIT Oh, swapping the params worked:

java --add-opens java.base/java.util=ALL-UNNAMED $JAVA_OPTS -Djava.util.logging.config.file="$DIR/logging.properties" -jar "$DIR/OsmAndMapCreator.jar"
mattmccutchen commented 1 year ago

@pyramid3d Looks to me like your issue is #484. Thanks for the workaround!