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

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

Merged

Conversation

dadul96
Copy link
Contributor

@dadul96 dadul96 commented Aug 24, 2020

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)

This solves the problem where this batch file may use a different Java version compared to the one provided by the Arduino IDE.
@stevstrong
Copy link
Collaborator

stevstrong commented Dec 15, 2020

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
Copy link
Collaborator

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
Copy link
Contributor Author

dadul96 commented Dec 15, 2020

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
Copy link
Collaborator

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
Copy link
Contributor Author

dadul96 commented Dec 15, 2020

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
Copy link
Collaborator

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:

  • in platform.txt (line 121):
- tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin"
+ tools.maple_upload.upload.pattern="{path}/{cmd}" {serial.port.file} {upload.altID} {upload.usbID} "{build.path}/{build.project_name}.bin" {runtime.ide.path}
  • in maple_upload.bat (line 8):
- java -jar maple_loader.jar %1 %2 %3 %4 %5 %6 %7 %8 %9
+ set PATH=%5\java\bin;%PATH%
+ java -jar maple_loader.jar %1 %2 %3 %4

Can you please try these changes and adapt this PR accordingly?

@dadul96
Copy link
Contributor Author

dadul96 commented Dec 15, 2020

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.

Passes the Arduino IDE installation path to the batch file.
Passes the Arduino IDE installation path to the batch file.
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

Successfully merging this pull request may close these issues.

2 participants