Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.help > #2132
| 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-10-01 11:01 -0700 |
| Organization | A noiseless patient Spider |
| Message-ID | <k4clqg$29d$1@dont-email.me> (permalink) |
| References | <fead3281-6eb8-410b-9d07-19d8f9b00dea@googlegroups.com> <k4852u$qal$1@dont-email.me> <6efa5c08-67a8-4266-900d-b69bcc294a4a@googlegroups.com> <5fe6d862-7451-4f3b-a936-a11336cd2e47@googlegroups.com> |
On 10/1/2012 9:27 AM, piscesboy wrote: > On Sunday, September 30, 2012 8:33:32 PM UTC-4, Lew wrote: >> Knute Johnson wrote: >> >>> 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: >> >>> >> >> >> >> . . . >> >>>> HelloWorld.java:2: error: package javafx.scene does not exist >> >>>> import javafx.scene.Group; >> >>>> ^ >> >>>> HelloWorld.java:3: error: package javafx.scene does not exist >> >> >> >>> . . . >> >>>> 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. >> >> >> >> Clearly. >> >> >> >>> 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. >> >> >> >> This is one of the rare use cases where it actually makes sense to >> put the JAR >> >> in the "CLASSPATH" environment variable (along with "."). Doing >> this has perils, >> >> including necessitating the explicit mention of "." as a classpath >> element. >> >> Under most circumstances one would eschew "CLASSPATH" in favor of >> the more >> >> flexible and less damaging "-classpath" or "-cp" command-line >> parameter. >> >> However, when something is so much to be desired as a routine part >> of your >> >> build all the time as JavaFX might be in this instance, then the >> use of >> >> either "CLASSPATH" or even (gasp!) extension libraries becomes an >> option. >> >> >> >> Whatever you choose, make sure you have actually RTFMed on tools >> classpaths. >> >> >> >> -- >> >> Lew > > I compiled with the -cp option and now it compiles fine...but now it > fails to run when I invoke: > > java HelloWorld > > I get: > > Exception in thread "main" java.lang.NoClassDefFoundError: > javafx/application/Application at > java.lang.ClassLoader.defineClass1(Native Method) at > java.lang.ClassLoader.defineClass(ClassLoader.java:791) at > java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) > > at java.net.URLClassLoader.defineClass(URLClassLoader.java:449) > at java.net.URLClassLoader.access$100(URLClassLoader.java:71) at > java.net.URLClassLoader$1.run(URLClassLoader.java:361) at > java.net.URLClassLoader$1.run(URLClassLoader.java:355) at > java.security.AccessController.doPrivileged(Native Method) at > java.net.URLClassLoader.findClass(URLClassLoader.java:354) at > java.lang.ClassLoader.loadClass(ClassLoader.java:423) at > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at > java.lang.ClassLoader.loadClass(ClassLoader.java:356) at > sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:480) > > Caused by: java.lang.ClassNotFoundException: javafx.application.Application > at java.net.URLClassLoader$1.run(URLClassLoader.java:366) at > java.net.URLClassLoader$1.run(URLClassLoader.java:355) at > java.security.AccessController.doPrivileged(Native Method) at > java.net.URLClassLoader.findClass(URLClassLoader.java:354) at > java.lang.ClassLoader.loadClass(ClassLoader.java:423) at > sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308) at > java.lang.ClassLoader.loadClass(ClassLoader.java:356) > > > Again...this seems to be a missing class definition problem...which > leads me to believe there is a deeper flaw in how Java7 is set up in > my machine. > > I followed the instructions for downloading and installing Java7 > update 7 from the Oracle website, I used the Java Preferences > Application to set my default JDK to jdk 1.7.0 as per the > instructions, but now it's having all these different classpath > issues that do not happen when I use the standard Java 6 JDK from the > Apple vendor as opposed to the Oracle vendor Java 7 JDK. > I guess I should have been more complete, if you need the magic to compile, you will need the magic to run it too. -- Knute Johnson
Back to comp.lang.java.help | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll 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