Hi. 

If you need to detect J on windows using .NET code, I usually do it this way,

1. Create an instance of J and try to send or execute any command there.
2. Enclose the code in a try ... catch and handle the error.

The following example code does exactly that. I have a wrapper class called 
J.Session() which is a .NET wrapper to J.EXE, if any of the methods fail, it 
would assume that J is in the current directory and try to register it. You can 
use any other method of finding out where J is though.
        Try
            'What we do is we try to make an instance of jSession and close it 
immediately
            jSession = New J.Session(False)
            'Execute a magic number
            jSession.variable("WIFE", "Vilma")
            jSession.eval("temp=. i. 42")
            'If we got here, J is properly installed
            jSession.Dispose()
        Catch ex As Exception
            'Were here so that means J is not properly installed
            returnValue = False
            If (register) Then
                'We start by getting the application path
                appPath = 
System.Reflection.Assembly.GetExecutingAssembly.Location
                appPath = System.IO.Path.GetDirectoryName(appPath)
                'We now register the library
                Shell(appPath + "\j.exe /regserver", AppWinStyle.NormalNoFocus, 
True, -1)
            End If
        End Try

For more info on the J.NET wrapper class, go to: 
http://www.jsoftware.com/jwiki/Guides/J%20VB.NET

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Jack Andrews
Sent: Tuesday, July 07, 2009 9:38 AM
To: Programming forum
Subject: Re: [Jprogramming] detecting j on windows

>> > dir "%APPDATA%\Microsoft\Windows\Start Menu\Programs\j*"
>
> I guess you already got a solution.  What's wrong with it?  Or you
> prefer the J installer to add that to %PATH% automatically?

nothing wrong with it.  i just posted that solution for the benefit
of future readers of this thread.

while on the topic of %PATH%, it seems the equivalent of unix's
/usr/bin is c:\windows\system32.  i've been considering using
the system32 dir as an install location in the way unix dumps
binaries in /usr/bin.   no problems with %PATH% then :)

examples of exe's in system32:
  calc.exe
  ftp.exe
  java.exe
  notepad.exe
  mspaint.exe


ta, jack
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to