0

I'm trying to execute a Java program from a perl script.

In the command line I wrote:

java -cp C:\\Users\\Ivan\\workspace2\\Algo\\bin gale_shapely.gs1 1000

and it worked just fine.

When I try to transport it to my perl script like this:

#!/usr/bin/perl

use warnings;
use strict;

system("java -cp C:\\Users\\Ivan\\workspace2\\Algo\\bin gale_shapely.gs1 1000");

I run into the error:

'java' is not recognized as an internal or external command, operable program or batch file

I'm fairly certain that I added Java to my PATH variable as well. My PATH variable is:

%JAVA_HOME%;C:\Ruby193\bin;%PYTHONDIR%;%PERLDIR%;

with JAVA_HOME as:

C:\Program Files (x86)\Java\jdk1.8.0_11\bin

1 Answer 1

2

You could try giving the absoulte path to java in the system call.

Also notice that if the path has spaces in it, it is known to cause problems.

Try using PROGRA~2

Sign up to request clarification or add additional context in comments.

3 Comments

Would you suggest altering my Program Files (x86) to Program_Files_(x86)?
No, you can use the 8.3 filename (shown using dir /x) for Program Files (x86) it is PROGRA~2 Some people install java in a different path (i.e. C:\java), but yeah that is not very good. en.wikipedia.org/wiki/8.3_filename
This did the trick! Thank you. Will flag as the correct answer in 3 minutes!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.