NielsLiisberg / vscode-ibm-i-run-sql-with-acs

IBM i run SQL from ACS
Apache License 2.0
5 stars 2 forks source link

Feature request: Dynamically find ACS #1

Open ThePrez opened 3 years ago

ThePrez commented 3 years ago

The following Java code can dynamically locate ACS for you. I suspect it's tricky to include java stuff in your extension.

import java.util.prefs.Preferences;

public class AcsLoc {
    private static final String FALLBACK_PATH = "/usr/local/ibmiaccess/acsbundle.jar";
    public static void main(String[] args) {
        String acsPath = null;
        try {
            acsPath = Preferences.userRoot().node("com/ibm/iaccess/base").get("location_file", FALLBACK_PATH);
        }catch(final Exception e) {
            e.printStackTrace();
            acsPath = FALLBACK_PATH;
        }
        System.out.println(acsPath);
    }
}

To make this work without Java, you can inspect the registry key at HKEY_CURRENT_USER\SOFTWARE\JavaSoft\Prefs\com\ibm\iaccess\base on Windows or the xml in $HOME/.java/.userPrefs/com/ibm/iaccess/base for other platforms

ThePrez commented 3 years ago

You can also find the Java with the same approach

NielsLiisberg commented 3 years ago

Thanx JG for this input !! I appreciate that.

I was thinking of a way to do it, so I just made the Q&D solution to let the user enter it by hand ... not perfect .. I know.

The Java solution is not easy to do in typescript - but I think I will try to implement it with the registry / userpref method ..

Thank you so much .. I hope you will enjoy this extension - and any feedback is welcome !!

NielsLiisberg commented 3 years ago

Do you have an idea where it is on Mac?

$HOME/.java/.userPrefs/com/ibm/iaccess/base

Was not helpful so i tried

~/Library//Preferences/com.apple.java.util.prefs.plist

.. no luck either :(

ThePrez commented 3 years ago

On Mac, I thought it would be in ~/Library/Preferences/ so I am surprised it's not there. No worries though. Nobody does real work on Mac.

NielsLiisberg commented 3 years ago

Ha ha, so what about the registry stuff? Are anyone using windows out there?

Maybe an idea for you brilliant guys ( I miss so much btw) .. to place that information in a language AND os agnostic place?