[TIMOB-23314] Windows: CLI should find JDK like Studio does
GitHub Issue | n/a |
---|---|
Type | Story |
Priority | Medium |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2020-02-06T06:06:26.000+0000 |
Affected Version/s | Release 5.3.0 |
Fix Version/s | n/a |
Components | Tooling, Windows |
Labels | cb-tooling |
Reporter | Fokke Zandbergen |
Assignee | Chris Barber |
Created | 2016-05-04T14:19:58.000+0000 |
Updated | 2020-02-06T06:06:26.000+0000 |
Description
When I build a Windows app from Studio it works fine, but when I build the same app via CLI it fails with:
[ERROR] Failed to encrypt JavaScript files
[ERROR] Program launch failed. Unable to locate Java VM. Please set JAVA_HOME environment variable.
Which originates from:
https://github.com/appcelerator/titanium_prep/blob/247eaecf56160dce4273a8fd64977b83da671f06/android/launcher/main.jdk16.c#L139
Of course I could set JAVA_HOME
but if Studio manages to find Java (and apparently pass it on to the CLI) then why can't the CLI?
IMHO the CLI should be able to do anything Studio can. Even better: Studio should not do anything the CLI so that Studio is as light as it can be and relies on CLI.
I suppose we could look in the Windows Registry to find it. I wonder if that's what Studio does.
I'm not 100% certain, but either Studio gets the JDK info from Eclipse or it queries the Windows Registry. Titanium 6 will be using jdklib which I had already added Windows Registry checks (https://github.com/appcelerator/jdklib/blob/master/src/index.js#L297-L327), so already jdklib is better than the JDK detection code in node-appc. This ticket will resolved as fixed when Titanium 6 ships.
Awesome [~cbarber]! And then we should rip out the logic from Studio asap.
Currently, Titanium SDK uses the JDK detection code in
node-appc
. This code has been cleaned up and copied into https://github.com/appcelerator/jdklib. The new code supports searching the Windows Registry for the path.jdklib
is not ready for primetime and isn't designed to be dropped into the current Titanium SDK. Oncejdklib
is ready and integrated into the Titanium build, then we can resolve this ticket.The JDK detection code in node-appc has been moved into [jdklib](https://github.com/appcelerator/jdklib) and has been updated to check the Windows Registry. At this point, we should not update node-appc. It's legacy. I don't think we should replace node-appc's JDK detection with jdklib. It's not a drop in replacement. It makes the most sense to spend the time towards utilizing jdklib in the new build pipeline.