简体   繁体   English

为什么我不能在 JCreator 中使用 JavaFX?

[英]Why can't I use JavaFX in JCreator?

I'm currently using JCreator 5.0 and JDK 1.7.0_51.我目前使用 JCreator 5.0 和 JDK 1.7.0_51。 I haven't had any issues when coding, and this time I decided to adventure myself in the realms of JavaFX, but it seems I can't reach any of its content.我在编码时没有遇到任何问题,这次我决定在 JavaFX 领域冒险,但似乎我无法触及其中的任何内容。 Here's the error I get when I press the "Build File" button:这是我按下“构建文件”按钮时得到的错误:

H:\Tareas\Projects\Test\Test1.java:1: error: package javafx.stage does not exist
import javafx.stage.*;
^
1 error

So, my questions are:所以,我的问题是:

  • Is there something I'm doing wrong?有什么我做错了吗?
  • Am I missing something?我错过了什么吗?

I actually haven't coded anything yet, it just seems the import is not working.我实际上还没有编码任何东西,只是似乎导入不起作用。 This is the code so far, by the way, irrelevant I guess:这是到目前为止的代码,顺便说一句,我猜是无关紧要的:

import javafx.stage.*;
public class Test1 {
    public Test1() { }
}

Thanks in advance!!提前致谢!!

By the way, javafx.stage.* is not the only thing that gets me errors, in general, anything coming from javafx.* does the same :C, even "javafx.*" itself, I'm just using that as an example.顺便说一句,javafx.stage.* 并不是唯一让我出错的东西,一般来说,来自 javafx.* 的任何东西都是一样的:C,甚至“javafx.*”本身,我只是将它用作例子。 Cheers!干杯!

edit:编辑:

I solved it now!我现在解决了! and I did it thanks to @MadProgrammer , after reading the thread he provided me !感谢@MadProgrammer ,在阅读了他为我提供的线程后,我做到 Thanks very much =) it was so simple!非常感谢 =) 太简单了!

So what I found after reading the thread is that I needed to tell JCreator that such package existed, so I went through these steps in JCreator:所以我在阅读线程后发现我需要告诉 JCreator 这样的包存在,所以我在 JCreator 中完成了这些步骤:

  • went to "Configure" menu转到“配置”菜单
  • then 'Options"然后是“选项”
  • then selected "JDK Profiles" in the left menu然后在左侧菜单中选择“JDK Profiles”
  • then selected my "JDK version 1.7.0_51" profile然后选择了我的“JDK version 1.7.0_51”配置文件
  • then clicked the "Edit..." button然后单击“编辑...”按钮
  • then in the "Classes" tab clicked the "Add" button然后在“类”选项卡中单击“添加”按钮
  • then selected "Add Archive"然后选择“添加存档”
  • then went to my "C:\\Program Files\\Java\\jdk1.7.0_51\\jre\\lib" folder to select "jfxrt.jar"然后去我的“C:\\Program Files\\Java\\jdk1.7.0_51\\jre\\lib”文件夹选择“jfxrt.jar”
  • and finally opened it, click in "Ok", "Ok", et c.最后打开它,单击“确定”、“确定”等。 and volia!和 volia! no more errors!没有更多的错误!

Too long, didn't read : added "jfxrt.jar" to my JDK Profile in JCreator Options =)太长了,没看:在 JCreator Options 中将“jfxrt.jar”添加到我的 JDK Profile =)

Thanks very much!非常感谢!

I will be posting this as an answer soon, I just have to wait a couple hours due to having not enough reputation points, cheers everyone!我将很快将此作为答案发布,由于没有足够的声望点,我只需要等待几个小时,大家欢呼!

  • go to "Configure" menu转到“配置”菜单
  • then 'Options"然后是“选项”
  • then select "JDK Profiles" in the left menu然后在左侧菜单中选择“JDK Profiles”
  • then select your "JDK version 1.7.0_51" profile然后选择您的“JDK version 1.7.0_51”配置文件
  • then click the "Edit..." button然后单击“编辑...”按钮
  • then in the "Classes" tab click the "Add" button然后在“类”选项卡中单击“添加”按钮
  • then select "Add Archive"然后选择“添加存档”
  • then go to your "C:\\Program Files\\Java\\jdkX.X.X_X\\jre\\lib" folder to select "jfxrt.jar"然后去你的“C:\\Program Files\\Java\\jdkX.X.X_X\\jre\\lib”文件夹选择“jfxrt.jar”
  • and finally open it, click on "Ok", "Ok", et c.最后打开它,点击“确定”、“确定”等。 and done.并做了。

Too long, didn't read: add "jfxrt.jar" to your JDK Profile in JCreator Options =)太长了,没看:在 JCreator Options 中将 "jfxrt.jar" 添加到您的 JDK Profile =)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM