Java GUI in NetBeans on Mac OS X 10.8 - java

I'm currently studying a module at university about programming in java.
The IDE we are using is NetBeans and I am using Mac OS X 10.8
We have just started making a application that utilises a GUI.
I am following a worksheet and have followed it exactly.
Currently I am stuck because when I run my application the project builds fine but the GUI does not open when I run it.
My Project is built up of multiple packages and classes and I have set the GUI class as the main class.
Even more confusing to me is that I copied the project over to my Window 7 VM and it built and ran fine and the GUI came up.
Can anyone help as to why the GUI does not open on OS X and if there is a solution.
EDIT:
I get the following exception when I try to run my app on a Mac: http://pastebin.com/cySzY5Wr

Netbeans builds you application for a specific version of Java. However when you run the applicaton it will fail to run because the executables are of a previous version. To change the target JDK/Java Version in Netbeans you need to:
Go into the Project Properties(Right click on the project and select properties).
Then select the Libraries tab and check the JDK version. On OSX it should be JDK6 unless you've installed JDK7 from Oracle.
Then select the Compile tab(under Build) and check that the version that Netbeans is compiling for is the same or less than the JDK you are using.
You might also want to check the version of Java that you are running in the system(as this will be the version that is used when you double click on the .jar file.). You can do this by opening up Terminal.app(or search in Spotlight) and typing java -version.

Related

Cannot detect and install the selected platform. The java or javac may not be executable

I have recently installed netbeans 11. And open an existing maven project which is run properly on netbeans 8.2.That project runs on jdk1.7.In netbeans select manage platforms and I want to add jdk 1.7, there is error like that
Cannot detect and install the selected platform. The java or javac may not be executable.
I was facing same issue , was not able to add jdk 8 on netbeans 12.2.
In windows normally user do not have write access on "Program Files" folder , make sure if your netbeans is installed in Program Files directory run it as Adminstrator and then try to add new platform it will work.

JavaFx won't download on my MacBook Pro for Eclipse Oxygen

I have an assignment for my school that I have to submit that needs you to create a Java application that involves recursion, file read, and javaFx. I have a 15 inch MacBook Pro with an i7 processor. When I try to use JavaFx in a class in Java, I always get errors saying that javaFx.application.Application or javaFx.scene.Scene cannot be applied to a type. Basically, my Java oxygen application cannot run javaFx. I've tried multiple YouTube videos on how to download plugins from oracle and the Java oxygen marketplace. I told my instructor and he hasn't gotten back to me yet. Everytime I download a possible plugin like e(fx)clipse/2.0.0/ (or something like that), Java oxygen sends a message that it cannot complete the operation because new software has already been installed. I kept searching oracle for the latest JDK but javaFx still won't download. I was just wondering if it had to do with me having an Apple and not Windows computer or is there something else I can try. Thanks for your help!
Just go here and download the Mac version of the JDK and install it.
http://www.oracle.com/technetwork/java/javase/downloads/jdk10-downloads-4416644.html
That is all which is technically needed to run a JavaFX application. You should also download and install the latest version of Eclipse (Photon) because it fixes some problems with the latest Java.
http://www.eclipse.org/downloads/index-developer.php
If you like you can also install e(fx)clipse from the marketplace but it is not needed to write JavaFX applications.

Using the correct JDK or changing default in Netbeans on Linux OS

Disclaimer: I am new to Java, new to Linux, and new to Netbeans - apologies for any over/under explanation - please ask and I will add/remove info.
I have a model written in Java in Netbeans 8.2 that has been successfully running in NetBeans 8.2 on Mac OS. This version of NetBeans was downloaded with JDK8u171 (JDK/Java package).
All components of the model have successfully transferred through FTP (filezilla) to a remote Linux machine.
The Linux machine has a copy of Netbeans 8.2 and has java/1.8.0-oracle (and 1.6.0 and 1.7.0), and has java/1.8.0-openjdk (similarly, 1.6.0 and 1.7.0 also).
I am assuming that 1.8.0-oracle is the equivalent of JDK8u171 but I may well be wrong.
When I load netbeans using
module load java/1.8.0-oracle
module load netbeans
netbeans
The program opens (via remote desktop - x2goclient), and I can search for the project and open it.
Once open, I see:
'myprojectitle (broken)' in the project window on the left of the NetBeans GUI
right click -> resolve problems
...opens a screen saying
'The JDK is missing and is required to run some NetBeans modules Please use the --jdkhome command line option to specify a JDK installation or see http://wiki.netbeans.org/FaqRunningOnJre for more information.'
Does this mean I am using the wrong jdk/java package?
Or is the jdk package configured incorrectly in Netbeans, if so how can I reconfigure?
Any help would be greatly appreciated.
The solution to this was found at
The JDK is missing and is required to run some NetBeans modules
Whereby, java/1.8.0_171 needed to be installed and then netbeans needed to be opened as follows:
netbeans --jdkhome /path/java/1.8.0_171
Apologies for a repeat, but hopefully this answer can either redirect or offer a solution

Change Java version for Tomcat running from Netbeans when invoked

I have a set of projects under Netbeans that run on Java 1.7; I am starting one that depends on having Java 1.8. It is a web app, and both Netbeans and the Tomcat server that is configured under Netbeans need to run on 8 for the latter project, but cannot run on 8 for any of the former projects.
I was hoping to create a bat file or something that would allow me to specify the Java version for both Netbeans and the Tomcat that runs under Netbeans.
I found the command line argument for setting the jdkhome for Netbeans; that works for Netbeans. But the JDK configured for the server appears to be a Netbeans setting, and I don't know how to change that at the time that I invoke Netbeans, or with an environment variable (I tried JAVA_HOME, that didn't work).
Does anyone know how/whether this can be done?
Open netbeans IDE and go to Tools-->Servers
Then Select your server (tomcat) and on platform tab select your JDK version and lick on close button.
if Your JAVA platform is not listed in combo box click on Manage Platforms and add new JAVA Paltform.

Problems running JavaFX application on Java 1.7u80

I am using Netbeans 8.02 on the MAC and am creating a simple JavaFX application from the New Project Wizard.
When I set the platform to Java 1.8 it works just fine, but when I try to run it on Java 1.7u80 I get "java.lang.NoClassDefFoundError: javafx/application/Application". Behavior is the same when running from the IDE or from the command line.
Everything compiles just fine with either platform, so it does look like JavaFX is on the classpath for both platforms I have installed.
My target application will have to run on 1.7, so I cannot simply go with 1.8 and call it a day.
If you want to run JavaFx application on Java 1.7, you need to add jfxrt.jar into your classpath manually. In Java 1.8 jfxrt.jar is in the classpath by default. So that's why you got this problem while running it on 1.7.
You should be able to add it via your IDE. You can also use some third party tools like JavaFx Maven Plugin
It turns out I ran into this known bug in NetBeans IDE.
https://netbeans.org/bugzilla/show_bug.cgi?id=239388
It sounds like the path settings is causing the ide to use the Ant script which builds for platform V 1.8 by accident.
I changed the platform for Netbeans itself to be JDK 1.7 and now everything builds fine for 1.7 and runs the JavaFX app 100% using JDK 1.7u80.

Categories

Resources