Link to home
Start Free TrialLog in
Avatar of elepil
elepil

asked on

How to use environment variable in Netbeans' Properties dialog box (see pic)

User generated image
This is probably very simple. The above dialog box is arrived at by right-clicking on a JavaFX project, then selecting Properties, then clicking Run, and you should have something like the image.

Notice the pathname I highlighted within a red rectangle. That is the full path to my JavaFX SDK. I already have that entire path stored in an environment variable called PATH_TO_FX.

I tried to substitute the pathname with %PATH_TO_FX% (without quotation marks), but it didn't work.

So am I doing something wrong? Or does Netbeans simply disallow such notation? Can someone confirm?

What am I doing wrong? Or does Netbeans really do not accept environment variables in this part of its dialog box?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

I tried to substitute the pathname with %PATH_TO_FX% (without quotation marks), but it didn't work.
If you're going to try that, you probably would need double quotation marks as the path might (and does in your case) contain spaces. Having said that, those variables are expanded by the shell and its interpreters (such as cmd.exe) and Netbeans might not run it using a shell. You can only try it and see
Avatar of elepil
elepil

ASKER

I tried it like this with the quotation marks as you suggested:

--module-path "%PATH_TO_FX%" --add-modules javafx.controls,javafx.fxml

But I got this error:
Error occurred during initialization of boot layer
java.lang.module.FindException: Module javafx.controls not found
D:\Java\HelloFX\nbproject\build-impl.xml:1328: The following error occurred while executing this line:
D:\Java\HelloFX\nbproject\build-impl.xml:948: Java returned: 1
BUILD FAILED (total time: 0 seconds)

It couldn't find javafx.controls, so I guess what I did made Netbeans lose the classpath.

I am also thinking that Netbeans is able to handle JAVA_HOME without issue, and that could contain a pathname with spaces as well (and in my case, it does).

The reason this is important to me is because when I upgrade to a future version of Java FX (e.g. JavaFX 14 or higher), all I have to do is alter the value of the PATH_TO_FX environment variable and all past JavaFX projects I have created will not have compile time errors.

If you have a Netbeans installation, have you tried to see if you can make a project work using an environment variable in the same spot I am inquiring about?
I am also thinking that Netbeans is able to handle JAVA_HOME without issue, and that could contain a pathname with spaces as well (and in my case, it does).
How is JAVA_HOME used in, and by, Netbeans?
Avatar of elepil

ASKER

Netbeans picks up JAVA_HOME's value automatically. I've installed Netbeans many times now, and each time, I'd set up the JAVA_HOME environment variable first, and Netbeans always picks it up and knows where my JDK installation folder is.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil

ASKER

I took a chance when I asked this question, hoping somebody might know something I don't. I wasn't necessarily optimistic there were alternatives; if that's how Netbeans was designed, that's the way it is.

Thank you for trying, CEHJ.
No problem. Since Netbeans uses Ant, you could use the 'env' approach in some way, though offhand, not precisely sure how:
https://www.oreilly.com/library/view/ant-the-definitive/0596001843/ch04s04.html
It would probably involve setting your JavaFX variable(s) as WIndows env var(s) first