rogerclarkmelbourne / Arduino_STM32

Arduino STM32. Hardware files to support STM32 boards, on Arduino IDE 1.8.x including LeafLabs Maple and other generic STM32F103 boards
Other
2.52k stars 1.26k forks source link

Fix Java PATH problem on Windows (Fix Issue #813) #814

Closed dadul96 closed 3 years ago

dadul96 commented 4 years ago

This solves the problem where this batch file may use a different Java version compared to the one provided by the Arduino IDE. (see Issue #813)

stevstrong commented 3 years ago

There might be a problem with this PR: as I can see, this will add the same string to PATH each time the batch file will be executed. I think there should be a safeguard implemented to add the string only if the string does not already exist in PATH.

stevstrong commented 3 years ago

According to this post the solution would be different, but I am not sure that such change is really needed. Usually, if you install Java it will add the new installation path to global PATH, so that after a PC restart the batch file should run ok.

dadul96 commented 3 years ago

There might be a problem with this PR: as I can see, this will add the same string to PATH each time the batch file will be executed. I think there should be a safeguard implemented to add the string only if the string does not already exist in PATH.

As far as I understand the PATH is only set temporarily. See: set-command

stevstrong commented 3 years ago

Ok, that might be true. However, the path you set here is a custom path. Many users (just like me) use the standalone package of Arduino IDE, which means that it may be then installed into another custom folder. In these cases this PR will not work, right?

dadul96 commented 3 years ago

Yes, that is correct. This PR will only affect users which installed the Arduino IDE in the default directory, but it won't break anything for other installation variants.

stevstrong commented 3 years ago

I think the best solution is to pass the Arduino IDE installation path to the batch file so that the correct path to Java can be set independent on the user preferences.

I have tested it and it works.

Necessary changes:

dadul96 commented 3 years ago

This solution is way better, thanks! I will update the PR tomorrow. There is only one change necessary to work properly:

- tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" {runtime.ide.path}
+ tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" "{runtime.ide.path}"

This allows having a space in the path string.