Java application not working with space in the path

L

luca.crespo

Hi all, i have a question.
I have a javas plugin which i should start usint a .bat file...
this one:

set classpath=.
cd c:\program files\fcm\plugin
java -jar MercatoLibero.jar %1 %2 %3

The problem is: since the "program files" has a space in the path, the
bat is not working... what can i do?
Thank you for your help!
 
T

Thomas Kellerer

Hi all, i have a question.
I have a javas plugin which i should start usint a .bat file...
this one:

set classpath=.
Not necessary at all, especially not when you use "java -jar"
cd c:\program files\fcm\plugin

that should be: cd "c:\program files\fcm\plugin"
(not the quotes around the filename)
The problem is: since the "program files" has a space in the path, the
bat is not working

Define "not working"
 
L

Lew

I have a javas [sic] plugin which i [sic] should start usint a .bat file....
this one:

set classpath=.

Thomas said:
Not necessary at all, especially not when you use "java -jar"

Note to OP: Setting the classpath is not necessary because "java -
jar" ignores the classpath, and even without "-jar" uses the current
working directory (cwd) as the classpath by default.


Thomas said:
that should be:  cd "c:\program files\fcm\plugin"
(not[e] the quotes around the filename)

The problem is: since the "program files" has a space in the path, the
bat is not working

This is an OS (Windows) question rather than a Java question, i.e.,
how do you get any program to recognize a command-line parameter that
contains a blank?

In particular for this scenario, how do you get 'cd' to recognize it?

Not a Java problem. Thomas Kellerer has given the answer.
 
L

luca.crespo

using:

cd "c:\program files\fcm\plugin"
java -jar MercatoLibero.jar %1 %2 %3

but still does not start the java app...
 
M

Martin Gregorie

using:

cd "c:\program files\fcm\plugin"
java -jar MercatoLibero.jar %1 %2 %3

but still does not start the java app...

Obvious question: is the jar file in that directory
Not-so obvious: does its Manifest file specify a Main-Class
is the specified class name correct
 
L

luca.crespo

Obvious question: is the jar file in that directory
Not-so obvious:   does its Manifest file specify a Main-Class
                  is the specified class name correct



Obvious: the jar is there
Not-so: can you specify what you mean? I have no idea what a Manifest
file or class name are, sorry...
 
T

Thomas Kellerer

(e-mail address removed), 11.02.2009 08:31:
Not-so: can you specify what you mean? I have no idea what a Manifest
file or class name are, sorry...

Is the jar file *intended* to be run with the "java -jar" command, or would you need to start it with something like:
java -cp MercatoLibero.jar the.main.Class

What error do you get when you run java -jar MercatoLibero.jar?
(make sure the commandline window stays open, so that you can read the error message)
 
R

RedGrittyBrick

Thomas said:
(e-mail address removed), 11.02.2009 08:31:

Is the jar file *intended* to be run with the "java -jar" command, or
would you need to start it with something like:
java -cp MercatoLibero.jar the.main.Class
What error do you get when you run java -jar MercatoLibero.jar?
(make sure the commandline window stays open, so that you can read the
error message)

I often add a "pause" command to the end of a Windows batch file so that
I get to see the actual error messages if invoked from a desktop icon,
scheduler, start/run etc.
 
R

Roedy Green

set classpath=.
cd c:\program files\fcm\plugin
java -jar MercatoLibero.jar %1 %2 %3

You problem is the CD command which does not like spacy dirnames. Why
did MS put a space in Program Files? It buggers up SO many things.
They were just showing off the new feature and wanted to force people
to modify their code to accept spacy filenames.

You must put the name in quotes. cd "c:\program files\fcm\plugin"

For hints on how to run Java programs, see:

http://mindprod.com/jgloss/javaexe.html

--
Roedy Green Canadian Mind Products
http://mindprod.com

"Here is a point of no return after which warming becomes unstoppable
and we are probably going to sail right through it.
It is the point at which anthropogenic (human-caused) warming triggers
huge releases of carbon dioxide from warming oceans, or similar releases
of both carbon dioxide and methane from melting permafrost, or both.
Most climate scientists think that point lies not far beyond 2°C (4°F) C hotter."
~ Gwynne Dyer
 
N

Nigel Wade

Obvious: the jar is there
Not-so: can you specify what you mean? I have no idea what a Manifest
file or class name are, sorry...

Where did you get the jar from? Are there any instructions on how to use it? Is
it even an executable jar? In what sense is the jar a "plugin", and how does
that relate to attempting to execute it without being "plugged in" to anything?

These questions, and many others, will be answered in the next episode...
 
J

John B. Matthews

Lew <[email protected]> said:
This is something you really must know before writing JARs intended
to run with the "-jar" option.

<http://java.sun.com/javase/6/docs/technotes/guides/jar/index.html>
<http://java.sun.com/docs/books/tutorial/deployment/jar/manifestindex.html>

Excellent reading. When tracking problems in the manifest, I've found it
useful to be able to examine the manifest _in_situ_:

<http://sites.google.com/site/drjohnbmatthews/manifesto>

to which I've added these informative references.
 
L

luca.crespo

Ok, here are some more infos...
- I have a program for a fantasy game called "fantacalcio" which
generates an internet site based on the infos of the program. The
"Mercato Libero" is a plugin launched at the end of the generation
that adds functions to the site.
- I have tried both cd "c:\program files\fcm\plugin" and cd c:
\"program files"\fcm\plugin and neither workerd. If i try to launch it
with the fantasy game program (how it's supposed to) seems there is no
bat/jar files: nothing happens at all
- I have tried to launch the MercatoLibero.bat through Vista folder
and Dos prompt and i have this error from Java Virtual Machine
Launcher: Could not find the main class: ml.MercatoLibero. Program
will exit

Hope some more stuff for you to help me, thank you in advance!
 
L

luca.crespo

This more: in prompt i type java -version:

java version "1.6.0_11"
Java(TM) SE Runtime Enviroment (build 1.6.0_11-b03)
Java HotSpot(TM) Client VM (build 11.0-b16, mixed mode, sharing)

The MercatoLibero plugin is supposed to have (written by the
developer): jre6.0 or jre1.6
 
M

Martin Gregorie

Ok, here are some more infos...
- I have a program for a fantasy game called "fantacalcio" which
generates an internet site based on the infos of the program. The
"Mercato Libero" is a plugin launched at the end of the generation that
adds functions to the site.
- I have tried both cd "c:\program files\fcm\plugin" and cd c: \"program
files"\fcm\plugin and neither workerd. If i try to launch it with the
fantasy game program (how it's supposed to) seems there is no bat/jar
files: nothing happens at all - I have tried to launch the
MercatoLibero.bat through Vista folder and Dos prompt and i have this
error from Java Virtual Machine Launcher: Could not find the main class:
ml.MercatoLibero. Program will exit
Is this 'MercatoLibero.bat' the same as the .bat file you've shown us?
- if not, where does it run and what java command is it using?
- if it is the same, try running:
makedir ml
copy MercatoLibero.jar ml\MercatoLibero.jar

and then running MercatoLibero.jar
 
L

luca.crespo

Is this 'MercatoLibero.bat' the same as the .bat file you've shown us?
- if not, where does it run and what java command is it using?
- if it is the same, try running:
     makedir ml
     copy MercatoLibero.jar ml\MercatoLibero.jar

  and then running MercatoLibero.jar

Those two in the prompt or in MercatoLibero.bat?
The one i have pasted in the first one is the .bat file, this one:

set classpath=.
cd c:\program files\fcm\plugin
java -jar MercatoLibero.jar %1 %2 %3

(tried also with quotes in the path, without success)
 
M

Martin Gregorie

Those two in the prompt or in MercatoLibero.bat? The one i have pasted
in the first one is the .bat file, this one:
IOW try putting a copy of the jar file in the ml directory since that's
what your game said it couldn't find when you ran it.

You still haven't told us whether the following code was in
MercatoLibero.bat:
set classpath=.
cd c:\program files\fcm\plugin
java -jar MercatoLibero.jar %1 %2 %3

though I'm guessing it wasn't, so tell us precisely what's in
MercatoLibero.bat or, better, put a copy in pastebin
http://pastebin.com

and tell us the URL so we can look at it.
 
L

Lew

Those two in the prompt or in MercatoLibero.bat?
The one i have pasted in the first one is the .bat file, this one:

set classpath=.

As mentioned upthread, setting classpath to "." is useless for three reasons here:
1. The envar is CLASSPATH.
2. If you don't set it, it defaults to "." anyway.
3. "java -jar" ignores the classpath.
cd c:\program files\fcm\plugin
java -jar MercatoLibero.jar %1 %2 %3

(tried also with quotes in the path, without success)

Did you read the links about JARs and manifests?
 
L

luca.crespo

Ok... gone on pastebin but, again, i'm sure the code i pasted before
(and on the site too) is the one in the bach file MercatoLibero,bat.
Anyway this is the link:

http://pastebin.com/m19b5b7ef

For Martin: done the ml subdirectory, copied the MercatoLibero.jar
file inside and launched the plugin: with prompt again the same Java
Virtual Machine error; if I start the program with the fantasy game
software nothing happens at all, as before.
For Lew: i'm not good with Java so i don't really know what to search
for in the manifest...
 

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
474,001
Messages
2,570,255
Members
46,853
Latest member
GeorgiaSta

Latest Threads

Top