starting java using process

Guiserver, GTK-server, OpenGL, PostScript,
HTML 5, MIDI, IDE
Locked
mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

starting java using process

Post by mostlywrong »

looking at the problem i have with running the demo programs newlisp is not starting java with the process function.
I have been trying to get Java to start from newlisp for several days now and pretty much out of ideas.
I can pretty much run any none java program with any arguments that i want using process to start them, except for java.
On another note I can start the java guiserver and pass in a newlisp source file using python..

Would i get different results using the console rather than newLISP Edit? That's where i have been working from so far.


Looking in the Tips and tricks section i found this:
Run a Win32 shell and hide window
and after a little fumbling it works.
what is the difference between process and the the win32 shell function?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Please try the following things from newLISP started in a command shell window (not the bottom part of the editor).

Code: Select all

> !dir
The exclamation mark should be the first character and the word: dir should immediately follow it.

If this works try the following:

Code: Select all

> (process "cmd /c dir")
and last:

Code: Select all

> (exec "dir")
Tell me if these things work. If these things work, try the same in the bottom shell windows of the newLISP-GS editor. If it works or not, in either case tell me what happens.
what is the difference between process and the the win32 shell function?
The win32 shell is a program running as a process. In the (process "cmd /c dir") example, newLISP starts the win32 shell as a new process and executes the "dir" command in it.

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

!dir
From cmd shell in the newlisp folder:
gives a dir listing of the "newlisp" folder.

From the lower pain of newLISP edit:
gives a dir listing of "C:\Documents and Settings\fred" which is the root of my login folder for my windows settings.

----------------------
(process "cmd /c dir")
From cmd shell in the newlisp folder:
gives nil

From the lower pain of newLISP edit:
gives nil

----------------------
(exec "dir")
From cmd shell in the newlisp folder:
gives an "extended" dir listing of the "newlisp" folder

From the lower pain of newLISP edit:
gives a "extended" dir listing of "C:\Documents and Settings\fred" which is the root of my login folder for my windows settings.

Code: Select all

> (main-args)
("C:\\newlisp\\newlisp.exe" "-C" "-w" "C:\\Documents and Settings\\fred")
From the lower pain of newLISP edit
---------------------------------------------------------------
I think my problem might have something to do with the arg passing to the program being called.

I was able to start guiserver with win32shell and pass in the newlisp file and have them both start. I wasn't able to do that with process. win32shell has a arg for cmd args.

Thanks for the help. It looks interesting and simple enough for a beginner to learn.

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

mostlywrong wrote:

Code: Select all

> (main-args)
("C:\\newlisp\\newlisp.exe" "-C" "-w" "C:\\Documents and Settings\\fred")
Is there a conflict with your newLISP not being installed in "C:\Program Files\newlisp"???

-- xytroxon
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

no. its the same problem. I moved new lisp folder to where you see it now and changed all the shortcuts and env settings tring to see if it was a "space in the path" problem.

thanks for asking though. bugging me to death.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

It should work in custom-chosen install directories too, as long as NEWLISPDIR and the executable path point to the correct location.

But back to what we were doing:

The 'process' function should display a directory listing too, but doesn't. Lets try the following in a cmd shell, to check if the shell program "cmd.exe" exists at all and is in the executable path with that name:

Code: Select all

cmd /c dir
if this still works, lets see if the newLISP 'process' function works with some other known program:

Code: Select all

> (process "notepad.exe")
This should pop up the Win32 notepad.exe editor. Try this in both the cmd shell and the the lower pane of newLISP edit.

Also what is this? C:\Program Files\Altiris\Software Virtualization Agent\

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

from a cmd prompt ( just happens to be in newlisp dir)

Code: Select all

cmd /c dir
gave me a dir listing of the current dir.
changed to c:\ and repeated and gave me dir listing of current dir.

from newlisp:

Code: Select all

(process "notepad.exe")
returned nil. no notepad.

Code: Select all

(process "c:/windows/system32/notepad.exe")
works and opens a notepad.

path problems? I'm not sure. I had done some testing of the pate before trying to rule it out.

I know this is comparing apples to oranges but...
using python prompt:

Code: Select all

import subprocess, os, sys
subprocess.Popen('notepad.exe',shell=True)
works. notepad opens.

If it is a path problem I'm not see it. Maybe a frese set of eyes could see it.

Code: Select all

> (env)
(("ADMINTOOLS" "C:\\Documents and Settings\\fred\\Start Menu\\Programs\\Administrative Tools")
 ("ALLUSERSPROFILE" "C:\\Documents and Settings\\All Users")
 ("APPDATA" "C:\\Documents and Settings\\fred\\Application Data")
 ("CACHE" "C:\\Documents and Settings\\fred\\Local Settings\\Temporary Internet Files")
 ("CDBURNING" "C:\\Documents and Settings\\fred\\Local Settings\\Application Data\\Microsoft\\CD Burning")
 ("COMMONADMINTOOLS" "C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Administrative Tools")
 ("COMMONAPPDATA" "C:\\Documents and Settings\\All Users\\Application Data")
 ("COMMONDESKTOP" "C:\\Documents and Settings\\All Users\\Desktop")
 ("COMMONDOCUMENTS" "C:\\Documents and Settings\\All Users\\Documents")
 ("COMMONFAVORITES" "C:\\Documents and Settings\\All Users\\Favorites")
 ("COMMONFILES" "C:\\Program Files\\Common Files")
 ("COMMONMUSIC" "C:\\Documents and Settings\\All Users\\Documents\\My Music")
 ("COMMONPICTURES" "C:\\Documents and Settings\\All Users\\Documents\\My Pictures")
 ("CommonProgramFiles" "C:\\Program Files\\Common Files")
 ("COMMONPROGRAMS" "C:\\Documents and Settings\\All Users\\Start Menu\\Programs")
 ("COMMONSTARTMENU" "C:\\Documents and Settings\\All Users\\Start Menu")
 ("COMMONSTARTUP" "C:\\Documents and Settings\\All Users\\Start Menu\\Programs\\Startup")
 ("COMMONTEMPLATES" "C:\\Documents and Settings\\All Users\\Templates")
 ("COMMONVIDEO" "C:\\Documents and Settings\\All Users\\Documents\\My Videos")
 ("COMPUTERNAME" "USER")
 ("ComSpec" "C:\\WINDOWS\\system32\\cmd.exe")
 ("COOKIES" "C:\\Documents and Settings\\fred\\Cookies")
 ("DEFAULTUSERPROFILE" "C:\\Documents and Settings\\Default User")
 ("DESKTOP" "C:\\Documents and Settings\\fred\\Desktop")
 ("FAVORITES" "C:\\Documents and Settings\\fred\\Favorites")
 ("FONTS" "C:\\WINDOWS\\Fonts")
 ("FP_NO_HOST_CHECK" "NO")
 ("HISTORY" "C:\\Documents and Settings\\fred\\Local Settings\\History")
 ("HOMEDRIVE" "C:")
 ("HOMEPATH" "\\Documents and Settings\\fred")
 ("LOCALAPPDATA" "C:\\Documents and Settings\\fred\\Local Settings\\Application Data")
 ("LOCALSETTINGS" "C:\\Documents and Settings\\fred\\Local Settings")
 ("LOGONSERVER" "\\\\USER")
 ("MEDIAPATH" "C:\\WINDOWS\\Media")
 ("MSSHAREDTOOLS" "C:\\Program Files\\Common Files\\Microsoft Shared")
 ("MYMUSIC" "C:\\Documents and Settings\\fred\\My Documents\\My Music")
 ("MYPICTURES" "C:\\Documents and Settings\\fred\\My Documents\\My Pictures")
 ("MYVIDEO" "C:\\Documents and Settings\\fred\\My Documents\\My Videos")
 ("NETHOOD" "C:\\Documents and Settings\\fred\\NetHood")
 ("NEWLISPDIR" "C:\\newlisp")
 ("NUMBER_OF_PROCESSORS" "1")
 ("OS" "Windows_NT")
 ("Path" "PATH=C:\\WINDOWS;C:\\WINDOWS\\system32;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\UltraEdit-32;C:\\Program
 Files\\Altiris\\Software Virtualization Agent\\;C:\\Program Files\\ATI Technologies\\ATI.ACE\\Core-Static;C:\\Program F
iles\\ActiveState Komodo Edit 5\\;C:\\Program Files\\Java\\jre6\\bin;C:\\newlisp")
 ("PATHEXT" ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.jar")
 ("PERSONAL" "C:\\Documents and Settings\\fred\\My Documents")
 ("PRINTHOOD" "C:\\Documents and Settings\\fred\\PrintHood")
 ("PROCESSOR_ARCHITECTURE" "x86")
 ("PROCESSOR_IDENTIFIER" "x86 Family 15 Model 12 Stepping 0, AuthenticAMD")
 ("PROCESSOR_LEVEL" "15")
 ("PROCESSOR_REVISION" "0c00")
 ("PROFILESDIRECTORY" "C:\\Documents and Settings")

 ("PROGRAMFILES" "C:\\Program Files")
 ("PROGRAMS" "C:\\Documents and Settings\\fred\\Start Menu\\Programs")
 ("PROMPT" "$P$G")
 ("RECENT" "C:\\Documents and Settings\\fred\\Recent")
 ("SENDTO" "C:\\Documents and Settings\\fred\\SendTo")
 ("SESSIONNAME" "Console")
 ("STARTMENU" "C:\\Documents and Settings\\fred\\Start Menu")
 ("STARTUP" "C:\\Documents and Settings\\fred\\Start Menu\\Programs\\Startup")
 ("SystemDrive" "C:")
 ("SystemRoot" "C:\\WINDOWS")
 ("TEMP" "C:\\DOCUME~1\\fred\\LOCALS~1\\Temp")
 ("TEMPLATES" "C:\\Documents and Settings\\fred\\Templates")
 ("TMP" "C:\\DOCUME~1\\fred\\LOCALS~1\\Temp")
 ("USERDOMAIN" "USER")
 ("USERNAME" "fred")
 ("USERPROFILE" "C:\\Documents and Settings\\fred")
 ("windir" "C:\\WINDOWS"))
>
Ok thats stright from the cmd prompt running newlisp with no editing.

DrDave
Posts: 126
Joined: Wed May 21, 2008 2:47 pm

Post by DrDave »

From what I was able to extract form your earlier posts, you did not install newLISP to the default settings. So, perhaps when you were moving things around, not all your paths match where your target files reside. For example, on my installation using the default settings, I have
("NEWLISPDIR" "C:\\Program Files/newlisp")
but you have
("NEWLISPDIR" "C:\\newlisp")

The first thing that I would have done when encountering such a problem is simply uninstall and then reinstall using the default settings.
...it is better to first strive for clarity and correctness and to make programs efficient only if really needed.
"Getting Started with Erlang" version 5.6.2

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

sorry I wasn't clear before.

I installed to the default dir at first.

Then moved to the root folder.

I will delete and reinstall to the default folder.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

lets continue with out experiments, in case you reinstalled, just check that NEWLIDPDIR and executable path are fine.

We have a problem with process not finding the path in (process "cmd /c dir"), Which is strange because the path environment variable seems to be fine. Same as on my XP-SP2 system, where both cmd and notepad are found using 'process'.

Lets try the following:

Code: Select all

(process "c:\\WINDOWS\\system32\\cmd.exe /c dir")

As you tried the same with notepad.exe it should work. If this works I will give you a modified guiserver.lsp. Where cmd.exe is called with its's full path

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

(process "c:\\WINDOWS\\system32\\cmd.exe /c dir")
works just fine.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

Put guiserver.lsp line 750 back to the original content; this assumes that your .jar -> javaw.exe association is working.

Then change line 1813 from:

Code: Select all

(process (string "cmd /c " server-path " " portIn))
to:

Code: Select all

(process (string "c:\\WINDOWS\\system32\\cmd.exe  /c " server-path " " portIn))
Now you should be able to do in a Win32 cmd shell:

Code: Select all

newlisp c:\newlisp\guiserver\buttom-demo.lsp

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

you got me Lutz. and it was painful. my eyes are not as good as they use to be.

Code: Select all

newlisp c:\newlisp\guiserver\buttom-demo.lsp
That m in buttoM killed me! :)

Things seem t work as expected now. Thank you for your Patience.

What it different about my machine that the path to CMD does not work like others ?

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

What it different about my machine that the path to CMD does not work like others ?
no idea, and sorry for the 'm' in button; I am glad it works now ;-)
Last edited by Lutz on Mon Jan 19, 2009 1:46 am, edited 1 time in total.

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

what is your path and maybe the (env) from newlisp.
programming is a hobby but PC troubles is like an itch.

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

i found it. i think let me make sure im using the original guiserver.lsp

copied from above:
("Path" "PATH=C:\\WINDOWS;C:\\WINDOWS\\system32;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\UltraEdit-32;C:\\Program
Files\\Altiris\\Software Virtualization Agent\\;C:\\Program Files\\ATI Technologies\\ATI.ACE\\Core-Static;C:\\Program F
iles\\ActiveState Komodo Edit 5\\;C:\\Program Files\\Java\\jre6\\bin;C:\\newlisp")
the problem probably has been floating around for a year or 2 waiting to bite me. I went back to the environment window and looked again. something about the system vs user pain was bugging me. finally i saw that the environment had the word path 2 times. once as a lable and once with an equal. i cant tell you how many time i have seen path=%path%;something in config files. somewhere mine lost the %path% and left the path= hanging in value side. took it out and all is well.

I'd like to thank you again for helping me solve this.
Last edited by mostlywrong on Mon Jan 19, 2009 1:58 am, edited 1 time in total.

Lutz
Posts: 5289
Joined: Thu Sep 26, 2002 4:45 pm
Location: Pasadena, California
Contact:

Post by Lutz »

On my XP-SP2 installation:

> (env)
(("ALLUSERSPROFILE" "C:\\Documents and Settings\\All Users") ("APPDATA" "C:\\Documents and Settings\\lutz\\Application Data")
("CLIENTNAME" "Console")
("CommonProgramFiles" "C:\\Program Files\\Common Files")
("COMPUTERNAME" "WINDOWS")
("ComSpec" "C:\\WINDOWS\\system32\\cmd.exe")
("FP_NO_HOST_CHECK" "NO")
("HOMEDRIVE" "C:")
("HOMEPATH" "\\Documents and Settings\\lutz")
("LOGONSERVER" "\\\\WINDOWS")
("NEWLISPDIR" "C:\\Program Files\\newlisp")
("NEWLISPLIB_INIT" "c:\\lib-init.lsp")
("NUMBER_OF_PROCESSORS" "1")
("OS" "Windows_NT")
("Path" "C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\WINDOWS\\System32\\Wbem;C:\\Program Files\\newlisp")
("PATHEXT" ".COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH")
("PROCESSOR_ARCHITECTURE" "x86")
("PROCESSOR_IDENTIFIER" "x86 Family 6 Model 15 Stepping 6, GenuineIntel")
("PROCESSOR_LEVEL" "6")
("PROCESSOR_REVISION" "0f06")
("ProgramFiles" "C:\\Program Files")
("PROMPT" "$P$G")
("SESSIONNAME" "Console")
("SystemDrive" "C:")
("SystemRoot" "C:\\WINDOWS")
("TEMP" "C:\\DOCUME~1\\lutz\\LOCALS~1\\Temp")
("TMP" "C:\\DOCUME~1\\lutz\\LOCALS~1\\Temp")
("USERDOMAIN" "WINDOWS")
("USERNAME" "lutz")
("USERPROFILE" "C:\\Documents and Settings\\lutz")
("windir" "C:\\WINDOWS"))
>

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

just in case you missed it. i edited my last post to say i found the trouble and the original guiserver.lsp now works like a champ.

xytroxon
Posts: 296
Joined: Tue Nov 06, 2007 3:59 pm
Contact:

Post by xytroxon »

mostlywrong wrote:just in case you missed it. i edited my last post to say i found the trouble and the original guiserver.lsp now works like a champ.
Great!

Proving once again that there is no such thing as a stupid question. Your thread helped me to understand a few things more about enviroment vars and paths and to clean up somethings on my machine :)

And by posting this thread, your PATH variable will live on forever**

In my browser, I highlighted and copied your PATH variable to check it out in my editor. (That period in "\\ATI.ACE\" looked strange to me, but is legal.) Forgetting, I accidentally opened a Google search with it. And to my surprise, Google found this thread!

-- xytroxon

** Forever. or until Google purges it!
"Many computers can print only capital letters, so we shall not use lowercase letters."
-- Let's Talk Lisp (c) 1976

mostlywrong
Posts: 32
Joined: Fri Jan 09, 2009 10:54 pm

Post by mostlywrong »

wow! Google indexed the pages very quickly. i would not have thought it would be so quick.

Locked