0

I received this isue: com.sun.tools.javac.Main is not on the classpath. Oerhaps JAVA_HOME does not point to the JDK. It is currently set to "C:\Program Files\Java\jre7"

However, my JAVA HOME is set as follows:

C:\Program Files\Java\jdk1.7.0_51

With PATH

C:\Program Files\Java\jdk1.7.0_51

Any recommendations?

2 Answers 2

1

When node.js spawns a forked environment, it doesn't copy over your user's environment variables. You will need to do that manually.

You will need to get JAVA_HOME from process.env and set it in your exec() call. Something like this should work:

var config = {
    env: process.env
};
exec('javacmd', config,
    function() {
        console.log(arguments);
});

Or if you wanted to be more explicit, you could extract only the variables you needed (JAVA_HOME, etc) from process.env

See here for more details:

How to exec in NodeJS using the user's environment?

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

Comments

1

Just uninstall node js and re install node js. Its solve my problem.

Comments

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.