Where is javaws.exe??

R

Roedy Green

Something very puzzling is happening around javaws.exe the program you
use to kick off Java Web Start in Windows 2000.

First it does not appear to be on the path anywhere.

Second I can invoke it by typing javaws.exe on the command line. That
SHOULD be impossible.

Third I can't spawn it from C, though I can other exe files. Why can
command.com see it, but not exec?

I hope I am overlooking something obvious.


Anyone know of a tool that will scan the path and tell you about
multiple instances, and tell you which one you will actually get if
you type XXX.
 
R

Roedy Green

First javaws.exe does not appear to be on the path anywhere.

Second I can invoke it by typing javaws.exe on the command line. That
SHOULD be impossible.

This I have sort of tracked down. This mysterious behaviour only
occurs with 4NT not cmd.exe. It must be some path assist or history
feature of 4NT I am not aware of.

This now leaves me the question, given that Javaws.exe does not
install itself on the path, how the heck are you suppose to spawn it
on some unknown machine?

Does the JRE install set up a *.JNLP association or do you still have
to do that manually?
 
P

Paul Lutus

Roedy said:
Something very puzzling is happening around javaws.exe the program you
use to kick off Java Web Start in Windows 2000.

First it does not appear to be on the path anywhere.

Sure it is. By default it's located at c:\Program Files\Java Web
Start\javaws.exe
Second I can invoke it by typing javaws.exe on the command line. That
SHOULD be impossible.

Yes, if it was impossible, it would be impossible. But "Program Files" is
part of a typical Windows path.
Third I can't spawn it from C, though I can other exe files. Why can
command.com see it, but not exec?

It's a path issue. Give a complete path. The C exec code doesn't have access
to the PATH variable (or search algorithm) because no shell is launched.
I hope I am overlooking something obvious.

Just possible.
Anyone know of a tool that will scan the path and tell you about
multiple instances, and tell you which one you will actually get if
you type XXX.

Well, you could take the system path variable, break it into pieces and scan
each section separately, then show the located executables and their order
of precedence. Ironically, this is way easier to do using a typical Linux
installation than a typical Windows instllation.

But once you have Perl installed on both, it's easy on both.
 
R

Roedy Green

Third I can't spawn it from C, though I can other exe files. Why can
command.com see it, but not exec?

I have discovered though I can spawn a JNLP file if the association is
set up with this bit of C code.

if ( _spawnl( _P_OVERLAY, "c:\\winnt\\system32\\cmd.exe", "cmd.exe",
"/C", jnlpName, NULL )

The catch is, it does not work unless I hard code in the directory of
cmd.exe. It seems to refuse to search the path as advertised.

So now I have avoided the need to know where javaws.exe is , but now
need to know where cmd.exe is.

PHHT! I think I will end up having to search the disks or paths
myself. This is getting RIDICULOUS. I need to replicate the JNLP
file 26 times just to account for the fact I don't know ahead of time
which drive they will set their CD up as.
 
R

Roedy Green

I have discovered though I can spawn a JNLP file if the association is
set up with this bit of C code.

_spawnl( _P_OVERLAY, "c:\\winnt\\system32\\cmd.exe", "cmd.exe",
"/C", jnlpName, NULL )

However, this DOES work:

_spawnlp( _P_OVERLAY, "cmd.exe", "cmd.exe", "/C", jnlpName, NULL )

note _spawnlp.

_spawnl ignores the path. _spawnl "Searches" only the current
directory.
 
M

Mike

Does the JRE install set up a *.JNLP association or do you still have
to do that manually?

I don't recall having to do that once JWS is installed on the client. The
only thing that springs to mind is setting the mime type on a web server:

"To execute the application from a client machine, first make sure that you
have installed Java Web Start. Then simply point your browser to the URL for
the jnlp file. The Java Web Start client will download the jnlp file,
download the necessary resources, and launch the application."

http://developer.java.sun.com/developer/JDCTechTips/2001/tt0530.html

http://java.sun.com/features/2002/10/webstart.html

M
 
P

Paul Lutus

I have discovered though I can spawn a JNLP file if the association is
set up with this bit of C code.

if ( _spawnl( _P_OVERLAY, "c:\\winnt\\system32\\cmd.exe", "cmd.exe",
"/C", jnlpName, NULL )

That's because the shell you launched has access both to the PATH variable
and to the shell's search algorithm.
The catch is, it does not work unless I hard code in the directory of
cmd.exe. It seems to refuse to search the path as advertised.

That is because before you launch "cmd.exe", you have to specify where
precisely where it is, because you don't have the PATH variable or the
search algorithm to help you.

BEFORE you launch cmd.exe, you must specify an exact path. AFTER you launch
cmd.exe, you have all the facilities of a shell to help you.
So now I have avoided the need to know where javaws.exe is , but now
need to know where cmd.exe is.

Yes, correct. It's true under any OS, by the way. Without a shell, you don't
have access to the shell's features.
PHHT! I think I will end up having to search the disks or paths
myself.

Or simply launch cmd.exe at the outset, ands use it to help you search.
This is getting RIDICULOUS. I need to replicate the JNLP
file 26 times just to account for the fact I don't know ahead of time
which drive they will set their CD up as.

No, there are several more efficient approaches, as above.
 
P

Paul Lutus

Roedy said:
This I have sort of tracked down. This mysterious behaviour only
occurs with 4NT not cmd.exe. It must be some path assist or history
feature of 4NT I am not aware of.

This now leaves me the question, given that Javaws.exe does not
install itself on the path,

But it does. Your impression is mistaken. It is on the search path.
how the heck are you suppose to spawn it
on some unknown machine?

By using the search path, and anything else available to assist you.
Does the JRE install set up a *.JNLP association or do you still have
to do that manually?

Depends on the platform, and also how you try to invoke it, and from where.
 
R

Roedy Green

I don't recall having to do that once JWS is installed on the client. The
only thing that springs to mind is setting the mime type on a web server:

I got friend to do a JRE install on a Java virgin machine, and lo to
my delight, it set up the association.

I now how have a self installing Java Web Start CD. I am 99% there. I
think the problem has to do when you use trailing / and when you
don't.

You just put it in, and up comes the familiar dialog box about "do you
Trust this Roedy Green fellah with this certificate."

The key is this little C: program that autorun.inf
kicks off.. It is crude but simple. It depends on 26 variants of the
JNLP file being automatically generated.


/**
* setup.cpp :
* invokes corresponding setup?.jnlp file when invoked from a CD
* setup.exe usually triggered by autorun.inf
* For windows only.
* copyright (c) 2003 Roedy Green, Canadian Mind Products
* #327 - 964 Heywood Avenue
* Victoria, BC Canada V8V 2Y5
* tel:(250) 361-9093
* http://mindprod.com
*/

#include "stdafx.h" /* standard precompiled header */

#include <direct.h> /* chdir, mkdir */
#include <process.h> /* exec, spawn */
#include <stdio.h> /* fclose, fgetc, printf, remove, rename, setvbuf
*/
#include <stdlib.h> /* exit, putenv, _splitpath */
#include <string.h> /* strcpy, strcat, strcmp, strupr */

/* Configure root name of all the jnlp files we might invoke */
const char* jnlpBaseName = "replicatorreceivercd";

// Java webstart is usually here, but we can't count on it.
// "C:\\Program Files\\Java\\j2re1.4.2_01\\javaws\\javaws.exe";

int main( int argc, char* argv[] )
{
// get current drive letter.
char curDrive = 'A' + _getdrive() - 1;

// generate name of jnlp file corresponding to CD drive letter
char jnlpName [50];
strcpy( jnlpName, jnlpBaseName );
// tack on drive letter
int baseLength = strlen( jnlpBaseName );
jnlpName[ baseLength ] = curDrive;
jnlpName[ baseLength + 1 ] = 0;
strcat ( jnlpName, ".jnlp" );
printf ("Installing %s with Java Web Start\n", jnlpName );

// start up Java Web Start with for example
replicatorreceiverR.jnlp
// cmd.exe on path in c:\winnt\system32
if ( _spawnlp( _P_OVERLAY, "cmd.exe", "cmd.exe", "/C", jnlpName,
NULL ) )
{
// ENOENT = 2 = not found
// EINVAL = 22 = invalid arg
printf ("Java Web Start must be installed first. Error %u\n",
errno );
}
return 0;
}
 
R

Roedy Green

Then simply point your browser to the URL for
the jnlp file. The Java Web Start client will download the jnlp file,
download the necessary resources, and launch the application."

All very well, but inside the JNLP file must be an ABSOLUTE reference
to where it and the associated files are.

The way I got around this was by generating 26 possible JNLP files,
one for each drive letter. Then to avoid confusing the heck out of
the user, I made it self-installing. The setup.exe written in C
selects and launches the correct JNLP file.

Another possible approach would be to have the setup program patch the
JNLP file, but then it can't write it back to the CD. You might try
to copy the generated file to C:. But then your codebase no longer
points to the CD. ARRGH!

I get the feeling someone at Sun went to great lengths to make this
difficult, for a reason I don't yet understand. They had to go to
extra work to block relative URLs.
 
P

Paul Lutus

Roedy said:
All very well, but inside the JNLP file must be an ABSOLUTE reference
to where it and the associated files are.

The way I got around this was by generating 26 possible JNLP files,
one for each drive letter.

Why don't you find the appropriate drive in code? By, for example, using:

File[] drives = File.listRoots();

Then searching those drives/roots for the appropriate files or paths? This
also has the advantage of being portable between platforms, which a scheme
that relies on Windows drive letters most certainly is not.
 
P

Paul Lutus

Roedy said:
I got friend to do a JRE install on a Java virgin machine, and lo to
my delight, it set up the association.

I now how have a self installing Java Web Start CD. I am 99% there. I
think the problem has to do when you use trailing / and when you
don't.

You just put it in, and up comes the familiar dialog box about "do you
Trust this Roedy Green fellah with this certificate."

The key is this little C: program that autorun.inf
kicks off.. It is crude but simple. It depends on 26 variants of the
JNLP file being automatically generated.

In a platform-portable language, this is unbelievable. You've prevented use
of your product on anything but Windows.
 
S

Skippy

The key is this little C: program that autorun.inf
In a platform-portable language, this is unbelievable. You've prevented use
of your product on anything but Windows.

It's only the autorun function that works this way on windows, so the app
itself will be runnable from any platform
 
T

Tim Tyler

Paul Lutus said:
Roedy Green wrote:

Sure it is. By default it's located at
c:\Program Files\Java Web Start\javaws.exe

That is not on my path. Is it /really/ on yours?
 
T

Tim Tyler

Roedy Green said:
I get the feeling someone at Sun went to great lengths to make this
difficult, for a reason I don't yet understand. They had to go to
extra work to block relative URLs.

I guess they want JNLP files to still work if they are downloaded and
cached.

It still seems like a pretty big screw-up to me.

Sun forgot about relocatability. An ironic mistake for a company
normally so keen on making things portable.
 
P

Paul Lutus

Tim said:
That is not on my path. Is it /really/ on yours?

Yes, in Windows 2000, standard installation of JDK 1.4.1(*). In any case, it
obviously is located *somewhere* on *any* system that launches javaws.exe
from the command line, and further, for the launch to have succeeded, the
search path must have included its location.


* I don't actually use Windows 2000. I keep a copy as a guest OS in VMware
under Linux only to answer questions like this.
 
R

Roedy Green

In which case you should be able to type "which foo".

this gives:

javaws is an external : C:\Program
Files\Java\j2re1.4.2_01\javaws\javaws.exe

However, that is not on the path. It is not an alias. How the heck is
it finding it?
 
R

Roedy Green

Otherise you'll need a copy of whereis/which for windows.

for future reference , the link to the which utility you can find via
either "path" or "which" in the Java glossary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top