Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2129

Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5...

From Knute Johnson <nospam@knutejohnson.com>
Newsgroups comp.lang.java.help
Subject Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5...
Date 2012-09-29 17:51 -0700
Organization A noiseless patient Spider
Message-ID <k4852u$qal$1@dont-email.me> (permalink)
References <fead3281-6eb8-410b-9d07-19d8f9b00dea@googlegroups.com>

Show all headers | View raw


On 9/29/2012 3:00 PM, piscesboy wrote:
> I just downloaded and installed the Java7 update 7 JDK for Mac OS X via the convenient .dmg installer on the Oracle website. JavaFX SDK is supposed to be included
>
> I want to get started on some example JavaFX applications...a simple HelloWorld app to get started using it and to verify that JavaFX works on my system. Here's the code for HelloWorld.java:
>
> import javafx.application.Application;
> import javafx.scene.Group;
> import javafx.scene.Scene;
> import javafx.scene.text.Text;
> import javafx.stage.Stage;
>
> public class HelloWorld extends Application {
>
>      @Override public void start(Stage stage) {
>          Scene scene = new Scene(new Group(new Text(25, 25, "Hello World!")));
>
>          stage.setTitle("Welcome to JavaFX!");
>          stage.setScene(scene);
>          stage.sizeToScene();
>          stage.show();
>      }
>
>      public static void main(String[] args) {
>          Application.launch(args);
>      }
> }
>
> I tried compiling via standard javac HelloWorld.java and the following error occurs:
>
> import javafx.application.Application;
>                           ^
> HelloWorld.java:2: error: package javafx.scene does not exist
> import javafx.scene.Group;
>                     ^
> HelloWorld.java:3: error: package javafx.scene does not exist
> import javafx.scene.Scene;
>                     ^
> HelloWorld.java:4: error: package javafx.scene.text does not exist
> import javafx.scene.text.Text;
>                          ^
> HelloWorld.java:5: error: package javafx.stage does not exist
> import javafx.stage.Stage;
>                     ^
> HelloWorld.java:7: error: cannot find symbol
> public class HelloWorld extends Application {
>                                  ^
>    symbol: class Application
> HelloWorld.java:9: error: cannot find symbol
>      @Override public void start(Stage stage) {
>                                  ^
>    symbol:   class Stage
>    location: class HelloWorld
> HelloWorld.java:10: error: cannot find symbol
>          Scene scene = new Scene(new Group(new Text(25, 25, "Hello World!")));
>          ^
>    symbol:   class Scene
>    location: class HelloWorld
> HelloWorld.java:10: error: cannot find symbol
>          Scene scene = new Scene(new Group(new Text(25, 25, "Hello World!")));
>                            ^
>    symbol:   class Scene
>    location: class HelloWorld
> HelloWorld.java:10: error: cannot find symbol
>          Scene scene = new Scene(new Group(new Text(25, 25, "Hello World!")));
>                                      ^
>    symbol:   class Group
>    location: class HelloWorld
> HelloWorld.java:10: error: cannot find symbol
>          Scene scene = new Scene(new Group(new Text(25, 25, "Hello World!")));
>                                                ^
>    symbol:   class Text
>    location: class HelloWorld
> HelloWorld.java:9: error: method does not override or implement a method from a supertype
>      @Override public void start(Stage stage) {
>      ^
> HelloWorld.java:19: error: cannot find symbol
>          Application.launch(args);
>          ^
>    symbol:   variable Application
>    location: class HelloWorld
>
>
> It is obvious that it is not finding the JavaFX library to compile. I did a search and found that the jfxrt.jar file is required to compile and run it. But it is located inside of the folder:
>
> /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/jre/lib
>
> which is inside of the JDK virtual machine folder for Java 7. I don't think there is any magic classpath command needed to compile this simple program but I could be wrong.
>

Yes you need the magic CLASSPATH to compile it.  I don't know why when 
the put FX in the JDK and JRE that it isn't already in the classpath but 
it isn't.  So just add it to your CLASSPATH and it will work just fine.

-- 

Knute Johnson

Back to comp.lang.java.help | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... piscesboy <oraclmaster@gmail.com> - 2012-09-29 15:00 -0700
  Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Knute Johnson <nospam@knutejohnson.com> - 2012-09-29 17:51 -0700
    Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Lew <lewbloch@gmail.com> - 2012-09-30 17:33 -0700
      Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... piscesboy <oraclmaster@gmail.com> - 2012-10-01 09:27 -0700
        Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Knute Johnson <nospam@knutejohnson.com> - 2012-10-01 11:01 -0700
          Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... piscesboy <oraclmaster@gmail.com> - 2012-10-01 11:32 -0700
            Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Knute Johnson <nospam@knutejohnson.com> - 2012-10-01 12:36 -0700
              Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... piscesboy <oraclmaster@gmail.com> - 2012-10-03 00:50 -0700
                Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Knute Johnson <nospam@knutejohnson.com> - 2012-10-03 06:39 -0700
            Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Jeff Higgins <jeff@invalid.invalid> - 2012-10-02 03:02 -0400
            Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Jeff Higgins <jeff@invalid.invalid> - 2012-10-02 03:16 -0400
              Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... piscesboy <oraclmaster@gmail.com> - 2012-10-03 00:46 -0700
                Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... markspace <-@.> - 2012-10-03 08:48 -0700
                Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Jeff Higgins <jeff@invalid.invalid> - 2012-10-03 16:00 -0400
        Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Lew <lewbloch@gmail.com> - 2012-10-01 13:10 -0700
          Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... piscesboy <oraclmaster@gmail.com> - 2012-10-01 18:38 -0700
            Re: Newbie Question: Help using JavaFX on Java 7 for Mac OS X 10.7.5... Lew <lewbloch@gmail.com> - 2012-10-02 15:55 -0700

csiph-web