Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-23314] Windows: CLI should find JDK like Studio does

GitHub Issuen/a
TypeStory
PriorityMedium
StatusClosed
ResolutionWon't Fix
Resolution Date2020-02-06T06:06:26.000+0000
Affected Version/sRelease 5.3.0
Fix Version/sn/a
ComponentsTooling, Windows
Labelscb-tooling
ReporterFokke Zandbergen
AssigneeChris Barber
Created2016-05-04T14:19:58.000+0000
Updated2020-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.

Comments

  1. Chris Barber 2016-05-04

    I suppose we could look in the Windows Registry to find it. I wonder if that's what Studio does.
  2. Chris Barber 2016-05-04

    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.
  3. Fokke Zandbergen 2016-05-05

    Awesome [~cbarber]! And then we should rip out the logic from Studio asap.
  4. Chris Barber 2017-08-09

    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. Once jdklib is ready and integrated into the Titanium build, then we can resolve this ticket.
  5. Chris Barber 2020-02-06

    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.

JSON Source