首页 > 解决方案 > getting started with JavaFX and environment variables

问题描述

I'm following the official tutorial to get started with JavaFX, and I'm on the step where you set the environment variable PATH_TO_FX. The tut provides two ways to set it, one for linux/mac and one for windows.

I am using Git Bash, which I think is supposed to simulate linux commands on a windows system (please correct me if I'm wrong).

I have tried to set the variable like so:

Linux/Mac: export PATH_TO_FX=C:/Program\ Files/JavaFX/javafx-sdk-11.0.2/lib/

Windows: set PATH_TO_FX="C:/Program Files/JavaFX/javafx-sdk-11.0.2/lib/"

The first way gives me an error that C:/Program is not a valid identifier, I think because of the space in the file path. I thought the \ was the escape character that would allow a space.

The Windows command gives me no feedback, but when I navigate to my environment variables in windows settings, the variable is not there. I can of course add it in the environment variables menu, but I'd like to understand the command line a bit better.

I have tried putting the path in quotation marks, and I tried with and without the escape slash that way too.

I have tried just putting "Program Files" in quotation marks, as one of the answers suggests.

I have tried the linux variation with and without a $ before the variable name.

I have also tried the Windows variation with and without the %% around the variable name.

I tried the windows variation in cmd as well as Git Bash.

Why is this happening and how do I fix it?

Also, a side question:

Is it it pretty normal that following the directions exactly don't work? It sure seems like it. Every time I want to set up a new system, library, IDE to learn how it works, I must first spend 5+ hours trouble shooting the installation. Following official directions never seems to work for me. Is this something I just have to get used to?

标签: javajavafxcommand-lineenvironment-variablesgit-bash

解决方案


The command SET is used to change the values of environment variables or to create new variables. In order to create user environment variables you have to use the command SETX , so that you have to use: SETX PATH_TO_FX "C:/Program Files/JavaFX/javafx-sdk-11.0.2/lib/"


推荐阅读