0

I have a problem with the local instance of my GlassFish(Payara)-server. I used to get following warning when I (re)deployd a JSP-Projekt via IntelliJ, even when the redeploy was successfull:

Address localhost:4848 is already in use

To fix this warning, I ended a running java-instance which was listening on this port. Ever since I try to redeploy my JSP-Project, I get the error message

I don't understand the format of this jvm-option: "-javaagent:C:\Program

every time. The server is not running thus I'm not able to connect with it. It's also not possible to start the GlassFish server manually via the console or the batch file.

It seems like there's a problem with the given file path of the jvm. Does anyone know how where it's stored and how to change it manually?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Hendrik
  • 175
  • 10

1 Answers1

0

The problem is with the space in C:\Program Files. The common solution to this is to surround the path with quotes, but this can sometimes get in a mess due to paths in quotes within other strings which are also enclosed in quotes. Consider something like this:

JAVA_HOME="C:\Program Files\some\path\to\java"

A script might use this environment variable but, being aware of the problem with spaces in Windows paths, surround the value of the environment variable with quotes again.

So, when it gets used, in something like this:

\"%JAVA_HOME%\bin\java.exe\" -jar myApp.jar

it will be:

""C:\Program Files\some\path\to\java"\bin\java.exe" -jar myApp.jar

So there are a set of quotes around nothing, which are effectively ignored, quotes around the end of the path and still a space which confuses things

You would need to know in advance how your scripts expect the path and be sure that no two scripts expect the path in a different format.

Windows has an alternative solution, though - these directories have short names, which do not contain spaces in the first place.

This SuperUser.com answer shows how you can find out the shortname for a given directory, so that you can rewrite the above to be as follows:

JAVA_HOME=C:\PROGRA~1\some\path\to\java

You now no longer have a problem with internal quotes and uncertainty about whether environment variables affect scripts

Community
  • 1
  • 1
Mike
  • 4,852
  • 1
  • 29
  • 48