0

I would like to use JavaFX for my game's start screen.

However, for some reason, the import "javafx" does not seem to be recognized.

enter image description here

At first, I (for some weird reason) thought I needed e(fx)clipse, however I successfully installed that and it does not fix the issue. I have found nothing else on the internet that fixes the issue.

Do I need to import javafx as a library or something? And if so, where?

Thanks!

4
  • 1
    Which version of Java are you using ? Commented Sep 16, 2014 at 14:18
  • In addition what is it 32 bit or 64 bit ? Commented Sep 16, 2014 at 14:19
  • @ItachiUchiha Java 1.7. Dunno any more than that. My PC (and java) is 64 bit. Commented Sep 16, 2014 at 14:32
  • Just use Oracle JDK 8+ for your development, for more detail see: Compile code using JavaFX 2.0 Commented Sep 16, 2014 at 21:08

3 Answers 3

2

Even in Java7, the javafx jar is included, but not in the classpath by default (you need java8 for that).

So, you could just copy the jfxrt.jar from your java installation's /lib directory into your local project's includes, and add it to the classpath there (ie. java -cp .*:lib/*)

Sign up to request clarification or add additional context in comments.

8 Comments

There is no "javafx.jar" or "jfxrt.jar" in "/lib". gyazo.com/37e146c01fe26ecc8ec778ccb97f06e6
@Joehot200 and it's called jfxrt.jar
@Joehot200 on my test vm here, it's under: C:\Program Files\Java\jre7\lib\jfxrt.jar -- so the regular jre directory... but the exact location may depend on your java7 version... javafx is/was considered experimental under java7.
I keep getting "RenderJob.run: internal exception" when I try to run the code? Whole error: pastebin.com/ntPAqp5p
@Joehot200 It could be a few things. JavaFX changed forms many times in java7, so even different versions of the jfxrt.jar might cause exceptions (the interfaces/api's changed, etc... still compile, but might blow up at runtime, etc). When I did this last, I found that java7_45 and lower worked, but any higher and the jfxrt.jar had some changed api's, and caused something similar in my app. You could try installing an older version of java7, then just grab it's jfxrt.jar and try using it instead of the one you have now.
|
1

You might probably missing right version jdk in your classpath.

above JDK 7u6 versions have JavaFX included with the standard JDK and JRE bundles so you can download it from Oracle website. Here is the link:

http://www.oracle.com/technetwork/java/javase/downloads/index.html

2 Comments

Ok, thanks.... So wait, what do I do after I download that JDK? What is this classpath you mean and how do I add it to the classpath? Sorry for being an idiot. xD
its ok that you dont know the classpath, i mean to say download above jdk7u6 version and point your project to this jdk and it will work for you. You can refer below youtube link: youtube.com/watch?v=EEcpMTpaWhs
1

I found the solution to this problem. Please refer and download the jdk 1.8 and installed.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.