I'm developing a Java Swing application using some features of JavaFX 2(such as WebBrowser).
I tried to reference the jfxrt.jar file from inside my folders, since it seems that a javaFX2 installer for MAC is not available (only installing Java 7).
But I would like to use JavaFX 2 also with Java 6.
I get this error:
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: java.lang.NoSuchMethodError: getScaleFactor
at com.sun.javafx.tk.quantum.QuantumToolkit.startup(Unknown Source)
at com.sun.javafx.application.PlatformImpl.startup(Unknown Source)
at javafx.embed.swing.JFXPanel.initFx(Unknown Source)
at javafx.embed.swing.JFXPanel.<init>(Unknown Source)
at javabrowser.JpJavaBrowser.initComponentsFx(JpJavaBrowser.java:63)
at javabrowser.JpJavaBrowser.<init>(JpJavaBrowser.java:59)
at orderbook.FrOrderBook.initComponents(FrOrderBook.java:625)
at orderbook.FrOrderBook.<init>(FrOrderBook.java:179)
at orderbook.FrOrderBook$2.run(FrOrderBook.java:681)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:715)
at java.awt.EventQueue.access$400(EventQueue.java:82)
at java.awt.EventQueue$2.run(EventQueue.java:676)
at java.awt.EventQueue$2.run(EventQueue.java:674)
at java.security.AccessController.doPrivileged(Native Method)
...
Caused by: java.lang.NoSuchMethodError: getScaleFactor
at com.sun.glass.ui.mac.MacApplication._initIDs(Native Method)
at com.sun.glass.ui.mac.MacApplication.<clinit>(Unknown Source)
at com.sun.glass.ui.mac.MacPlatformFactory.createApplication(Unknown Source)
at com.sun.glass.ui.Application.Run(Unknown Source)
... 23 more
How can I fix this?
JavaFX 2 does not support Java6 on OS-X - Java6 is only supported on win32
Related
I am stuck on the following error. I don't know what type of error it is. What should I do?
C:\Users\shehzad\Desktop\Software>java -jar Untitled.jar
Exception in thread "main" java.lang.UnsupportedClassVersionError: FrontEnd/MainWindow : Unsupported major.minor version 52.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$100(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoader.java:56)
Scenario is: I developed software that works fine in Ubuntu 14.04 Lts. It's JAR also works in Ubuntu, but when I tried this JAR
in Windows 7 it shows the above error.
Ubuntu Java version: 1.8.0_101
Windows Java version: 1.7.0_79
class version 52.0 means it requires Java 8 to run. You should for security reasons update your Windows Java anyway, so its time to go to Java 8. If you need Java 7 for something you can keep it as a private installation, but make sure the "javapath" as configured by the registry points to Java 8.
You can also start in a command window or via explorer link the right Java.exe without installing it as public version like this:
"c:\Program Files\java\jdk_1.8.0_102\bin\javaw.exe" -jar app.jar
Your jar file is compiled using 8u101 (major.minor version 52.0) and your trying to run on 7u79. Hence you end up in Unsupported major.minor version 52.0.upgrade your java to 8u101.
I have a javafx program that I was formerly developing in sublime text before migrating to intellij as my editing environment. As of now, I can compile and run without error through the command line (Windows). However, when I try to run it from intellij, I get the following message:
Exception in Application start method
Exception in thread "main" java.lang.RuntimeException: Exception in Application start method
at com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:875)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication$147(LauncherImpl.java:157)
at com.sun.javafx.application.LauncherImpl$$Lambda$1/868693306.run(Unknown Source)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3201)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3169)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3142)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3118)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3098)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3091)
at Main.setNewScene(Main.java:40)
at Main.start(Main.java:29)
at com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$153(LauncherImpl.java:821)
at com.sun.javafx.application.LauncherImpl$$Lambda$50/2069914884.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$runAndWait$166(PlatformImpl.java:323)
at com.sun.javafx.application.PlatformImpl$$Lambda$46/646648017.run(Unknown Source)
at com.sun.javafx.application.PlatformImpl.lambda$null$164(PlatformImpl.java:292)
at com.sun.javafx.application.PlatformImpl$$Lambda$48/1106256089.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at com.sun.javafx.application.PlatformImpl.lambda$runLater$165(PlatformImpl.java:291)
at com.sun.javafx.application.PlatformImpl$$Lambda$47/151108218.run(Unknown Source)
at com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
at com.sun.glass.ui.win.WinApplication._runLoop(Native Method)
at com.sun.glass.ui.win.WinApplication.lambda$null$141(WinApplication.java:102)
at com.sun.glass.ui.win.WinApplication$$Lambda$38/2004449016.run(Unknown Source)
... 1 more
Process finished with exit code 1
I don't know how to fix this.
The problem turned out to be intellij having an issue with the source folder in the project directory. By moving all my java files to a new directory and reopening it in intellij as a new project with a single, correct source folder, the problem completely went away.
(As stated in the question, the code itself was functional and worked through the command line.)
I am trying to run a java based java profiler to find out what uses up resources on my java application on my dedicated machine. The profiler I am trying to use is called warmroast.
I get the following error from running.
java -jar warmroast.jar
Exception in thread "main" java.lang.NoClassDefFoundError: com/sun/tools/attach/AttachNotSupportedException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at sun.launcher.LauncherHelper.validateMainClass(Unknown Source)
at sun.launcher.LauncherHelper.checkAndLoadMain(Unknown Source)
Caused by: java.lang.ClassNotFoundException: com.sun.tools.attach.AttachNotSupportedException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 6 more
I think this error is caused by running the file with jre instead of jdk.
I have installed java-1.7.0-openjdk-1.7.0.55-2.4.7.1.el6_5.x86 as a yum package.
[root# ~]# java -version
java version "1.7.0_55"
OpenJDK Runtime Environment (rhel-2.4.7.1.el6_5-x86_64 u55-b13)
OpenJDK 64-Bit Server VM (build 24.51-b03, mixed mode)
I think to fix this problem, I will need to run the jar file using jdk. Is there some kind of a jdk path to the jdk bin file? If so, what is it in centos? I've googled for a while and came up with dozens of wrong paths. I feel stupid because I think jre is a part of jdk and jdk is only using for compiling stuff and I don't think you can run files with jdk...
...
...
The class that could not be found is in tools.jar in your JDK. This library is usually not automatically on the class path, even if you use JDK instead of JRE.
According to the documentation, on Linux warmroast should be started as follows (replace PATH_TO_JDK with the path to your JDK):
java -Djava.library.path=PATH_TO_JDK/jre/bin -cp PATH_TO_JDK/lib/tools.jar:warmroast-1.0.0-SNAPSHOT.jar com.sk89q.warmroast.WarmRoast --thread "Server thread"
Here, tools.jar is manually added to the classpath.
I have an SWT application that I've developed on OSX, so it contains the Mac version of the SWT libraries.
Now I need to run this application on a Windows machine. I export the application to a .jar file, but when I attempt to execute the jar in Windows, I get:
Exception in thread "main" java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:
no swt-cocoa-4236 in java.library.path
no swt-cocoa in java.library.path
Can't load library: \\psf\Home\.swt\lib\win32\x86\swt-cocoa-4236.dll
Can't load library: \\psf\Home\.swt\lib\win32\x86\swt-cocoa.dll
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.Library.loadLibrary(Unknown Source)
at org.eclipse.swt.internal.C.<clinit>(Unknown Source)
at org.eclipse.swt.widgets.Display.<clinit>(Unknown Source)
at display.StoragePickupDisplay.open(StoragePickupDisplay.java:70)
at display.StoragePickupDisplay.main(StoragePickupDisplay.java:58)
... 5 more
I have added the Windows version of SWT libraries but that didn't make a difference. I need the Mac libraries to be in there for continued development. How can I get around this?
You have to add the correct SWT.jar to the classpath. You can download them here.
If you are deploying for Windows, you will have to bundle the swt jar for Windows (either 32bit or 64bit depending on the system).
If you want to create an application that runs on all platforms, have a look at this post:
Create cross platform Java SWT Application
When I run mobile application in netbeans 6.9.1 it shows me below error in output window.
it doesn't allow me to start emulator.
java.lang.UnsatisfiedLinkError: /home/devindia/netbeans-6.9.1/mobility/WTK2.5.2/bin/sublime.so: /home/devindia/netbeans-6.9.1/mobility/WTK2.5.2/bin/sublime.so: wrong ELF class: ELFCLASS32 (Possible cause: architecture word width mismatch)
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1750)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1646)
at java.lang.Runtime.load0(Runtime.java:787)
at java.lang.System.load(System.java:1022)
at com.sun.kvem.Sublime.<init>(Unknown Source)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:532)
at java.lang.Class.newInstance0(Class.java:372)
at java.lang.Class.newInstance(Class.java:325)
at com.sun.kvem.Lime.createLime(Unknown Source)
at com.sun.kvem.KVMBridge.<init>(Unknown Source)
at com.sun.kvem.KVMBridge.getBridge(Unknown Source)
at com.sun.kvem.midp.MIDP.run(Unknown Source)
at com.sun.kvem.environment.EmulatorInvoker.runEmulatorImpl(Unknown Source)
at com.sun.kvem.environment.EmulatorInvoker.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:616)
at com.sun.kvem.environment.JVM.main(Unknown Source)
/home/devindia/NetBeansProjects/MobileApplication1/nbproject/build-impl.xml:898: Execution failed with error code 1.
BUILD FAILED (total time: 8 seconds)
I use ubuntu 10.4. 64 bit machine.
Looks like there is no way to run mobile emulator on x64-jdk (in linux), so you additionaly need to install x32-jdk to compile and run your ME-projects with it.
Usually this error means a mismatch in the java runtime. Are you running your code in 64 bit java runtime. ( I guess you downloaded Netbeans for 64bit linux)