开始使用JavaFX和环境变量

huangapple go评论108阅读模式
英文:

getting started with JavaFX and environment variables

问题

我正在按照官方教程开始使用JavaFX,并且我现在处于设置环境变量 PATH_TO_FX 的步骤。教程提供了两种设置的方法,一种适用于Linux/Mac,另一种适用于Windows。

我正在使用Git Bash,它我认为是用于在Windows系统上模拟Linux命令的(如果我错了,请纠正我)。

我尝试设置变量如下:

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/"

第一种方法会出现错误,指示 C:/Program 不是一个有效的标识符,我认为这是由于文件路径中有空格。我认为 \ 是转义字符,可以允许使用空格。

Windows 命令没有给出任何反馈,但是当我在Windows设置中导航到我的环境变量时,该变量不存在。当然,我可以在环境变量菜单中添加它,但我想更好地理解命令行。

我尝试了将路径放在引号中,并且也尝试了在引号中使用和不使用转义斜杠。

我尝试仅将 "Program Files" 放在引号中,正如其中一个答案建议的那样。

我尝试了在变量名之前加上 $ 的Linux变体。

我还尝试了在变量名周围加上 %% 的Windows变体。

我在 cmd 和 Git Bash 中都尝试了Windows变体。

为什么会发生这种情况,我该如何修复?

此外,还有一个附加问题:

按照准确的指示不起作用,这种情况相当正常吗?似乎确实是这样。每当我想要设置新的系统、库、IDE以了解其工作原理时,我必须首先花费5个多小时来解决安装问题。按照官方指示似乎从来都不起作用。我只需适应这种情况吗?

英文:

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?

答案1

得分: 1

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/"

英文:

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 <variable> <value>, so that you have to use: SETX PATH_TO_FX "C:/Program Files/JavaFX/javafx-sdk-11.0.2/lib/"

huangapple
  • 本文由 发表于 2020年4月10日 09:15:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/61132643.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定