netbeans project doesn't run when jre 7 installed - java

I have a rather large NetBeans 7.0.1 project, which is released as an installer. When a second PC has this program installed, and has Java 6 installed, it runs fine, however if this PC happens to have Java 7 installed, some parts of the program fail.
Why is this and how can I solve this?
One part where it fails: there is a bean class that, when right-clicked in the GUI, shows a pop-up menu with 'Properties'. When clicked, it opens a property sheet, however, fields which are not primitive types show "(No Property Editor)". I can't trace this back because most of the logic happens within native NetBeans API code and a lot of Reflection is used.
Edit: I also installed NetBeans 7.4 with Java 7 on the development machine, changed all modules to 1.7 source, recompiled, but the problem persists.

There are a lot of differences between Java 6 and 7 so pointing to the specific problem is difficult. Probably the API's you are using are based on Java 6. You have two options make your project Java 7 compatible or install Java 6 on the machines that use your project/application. The latter would be the easiest in my opinion.

Related

How to run java program using Oracle JDK 17, if Oracle JDK 17 does not come with JRE [duplicate]

This question already has answers here:
How can I get Java 11 run-time environment working since there is no more JRE 11 for download?
(4 answers)
Closed 3 years ago.
We are planning to migrate our Java 8 project to use Java 11. But I noticed that Java 11 doesn't have a JRE folder.
In Java 9 and Java 10, folder structures are changed i.e. java\jdk1.x or java\jre1.x, where x is Java 9 or 10.
But in Java 11, I am getting only one folder, i.e. java\jdk-11. How will my client use my application without jre?
What I understood is that Java 11 is enforcing to modularize our application, and using jlink is needed to create our own jre to run the application in client.
Is my understanding correct?
For 20 years, the JDK shipped with a JRE which was just a subset of its functionality installed in a different directory on your system.
In fact, it shipped with TWO identical JREs, one installed inside the JDK installation directory and one outside it.
This has always puzzled me as it's a complete waste of effort on the part of the maintainers to make this so, and a complete waste of disk space on the computer you install it on, as that JRE just duplicates some of the things the JDK can do already.
Finally, with Java 11, Oracle and the OpenJDK team decided to end this silliness and just distribute a single thing, the JDK.
This JDK when installed is actually smaller on your hard disk than the old JRE alone used to be, removing even the somewhat valid argument that you'd want a separate JRE for devices with limited disk space, an argument that never explained why 2 JREs would be installed with a single JDK in the first place but was made to justify the need for a JRE as a stripped down runtime environment for the JDK.
Ergo, there is no need for a separate JRE, and there hasn't been one for a long time, let alone for including and forcibly installing it as part of the JDK installation.
And no, you don't need to create your own JRE. Just install the OpenJDK on the client machines and make sure you add the $JAVA_HOME/bin to the system path, just as you had to do with old JREs.
And oh, strip the Windows directory tree of any java*.exe files which some versions of the old JRE installer were wont to place there, as well as the system path which also had some weird entries added by some JRE installers.
tl;dr
How will my client use my application without jre?
➥ Bundle a Java implementation within your Java-based app.
Learn about:
Java Platform Module System
jlink (JEP 282)
jpackage (JEP 343)
Details
What I understood is that Java 11 is enforcing to modularize our application
No, modularization is not required, strictly speaking. Most existing apps can run as-is in Java 11. You can continue to develop in Java 11 without modularizing your code. But in your case, for a GUI desktop or mobile app, then you need to package a JVM within your app. Modularizing and using jlink tooling is probably the best way to go about that. In contrast a server-side Servlet-based app or Microservices server need not yet modularize, though likely a good idea to do so eventually.
I noticed that Java 11 doesn't have a JRE folder.
Oracle no longer intends for end-users to be installing a JRE or a JDK. Java Applets in a browser and Java Web Start app delivery are both being phased out, leaving the end-user with no need for a JRE. Java-based apps are expected to bundle their own Java implementation. The only folks consciously installing a JDK will be developers & server-side sysadmins.
Some folks are disappointed to see the passing of the Java Everywhere dream. And they may be annoyed to have to make a build of their app for every host OS (macOS, Linux, Windows, etc.). On the other hand, some developers are happy to be bundling a Java implementation (now smaller than ever) with their app, as that eliminates the hassle for the end-user to download-install-update a system-wide Java implementation. Also eliminates wrestling with corporate IT departments to install Java on users’ PCs. And bundling Java with app simplifies testing and support, as you know and control exactly what version and distribution of Java is involved. By the way, this bundling-Java-with-app is not exactly new: It has been supported by Apple for many years in the macOS & iOS app stores.
Important:
Understand clearly the nature of the OpenJDK project, as explained in Wikipedia
Read this white paper by Oracle of 2018-03, Java Client Roadmap Update
Read the white paper Java Is Still Free, authored by key members of the Java community.
Here is a flowchart diagram that may help you finding and deciding amongst the various vendors providing a Java 11 implementation.
Look at the AdoptOpenJDK project website to download the latest JRE and JDK.
I have used their nightly builds to work around the problem of missing JRE in JDK package. Just unpack JRE into JDK folder and this is going to be it.

Is there a JRE for JDK 14? [duplicate]

This question already has answers here:
How can I get Java 11 run-time environment working since there is no more JRE 11 for download?
(4 answers)
Setting the correct PATH for Eclipse
(7 answers)
Closed 2 years ago.
I have been having trouble with Java for my studies. I downloaded the latest version of the JDK, JDK 14. Now I tried to install Eclipse, it states that I do not have a JVM. So I am trying to download the JRE for it, but there is none. Can anyone recommend to me what I should do? Or do I need to uninstall the newest version and download a lower version?
No.
a JDK is a superset of a JRE; anything a JRE can do, a JDK can do. There is never any reason to install a JRE and there never has been*.
JREs are intended for 'end users' (non-coders who just want to run java apps, not write them or debug them). The model where you write an app and distribute some jars, and the user that receives your desktop java app is then responsible for having a java virtual machine on their machine (and they are responsible for keeping it up to date, secure, etc) – is dead. It died with JDK9. Officially. Replaced by jlink and such. That's why JDK9 has no JRE, nor do any versions after wards, and they never will again.
Because, starting with JDK9, you are responsible for that VM. You install it, you update it. jlink and co. help with this.
Eclipse, intellij, etc tend to still rely on you installing a JDK yourself; after all, you need one to develop java, so might as well use that. The point is, eclipse has run on JDKs since forever.
If the eclipse installer has issues finding your VM, that's possibly because JDK14 is brand new and whilst the latest version of eclipse does support it, maybe you have an older one. I suggest trying JDK11 (you really shouldn't run java apps on not-JDK11/JDK8; you'd want a long-term support version). Eclipse is perfectly fine running on JDK11, whilst you have a project that compiles against, and only runs on, JDK14. You can still run it, debug it, etc.

does eclipse have it's own JDK? or it uses the JDK on my computer?

I'm new to java programming and I haven't used any java IDE,
I intalled Java JDK 8 on my computer and been doing some coding through Notepad++ and compiling it via cmd commands.
Since now that i'm comfortable coding manually, I wanna try to use IDE and decided to get the latest "Eclipse IDE for Java Developers". what I got is actually a .zip file no installation or something which is odd.
My question is does the eclipse uses the JDK I installed on my computer or it has it's own? if so how would I know which version of java does my eclipse run?
and if does use the JDK on my computer, if I want to update the JDK intalled on my computer do I have to uninstall the old one or I can just overwrite it with the new JDK build??
Thanks,
CC
Eclipse uses externally installed JDKs to run itself (it's written in Java, after all) and to provide the core libraries for the code you write (such as the java.* packages). By default, Eclipse will use its own compiler, ECJ, that has deep integrations with the IDE to provide features such as detailed error reporting and sometimes even partial compilation of invalid classes.
It's possible to override the compiler via some plugin (for example, you can explicitly specify a compiler in a POM via m2eclipse, though the default there still uses ECJ), but that's uncommon if you're still compiling Java code.
Eclipse has support for using multiple JDKs, for example for different versions (maybe you have backwards compatibility with 1.6) or different vendors. Depending on how your OS is set up, if your main JAVA_HOME is set through a symlink, you may not need to update Eclipse at all if you perform a minor upgrade. In the case of a major upgrade, though, you will probably need to go to "Installed JREs" and add or modify an entry.
1.the jdk you installed in your computor is global situation. it can effect anywhere if you have configured the environment variables.
2.configured the environment variables,run cmd like this,the java version will be show,enter image description here
3.generally, one JDK , one computor is enough.if you want to update jdk, just download new jdk and override the old jdk .

How to downgrade a java application developed in Java 8 to Java 7 or lower

I created a java desktop application using net beans in java version 8 environment. The application is running successfully in my machine. But if i try to run the application in a computer which is having java 7 or lower, it is throwing Unsupported major.minor version 52.0 error. What changes i have to make so that the application runs on other versions without errors? Do i need to develop the whole application again using lower versionof java?
With a bit of luck, you just need to recompile your code with a lower jdk version.
But, if you have used new technologies (Lambda's, ... ), yes, you will need to re-write certain parts of your code.
In NetBeans:
Right click on your project
Click on Properties
Go to Sources in the Properties window
Change Source/Binary Format to JDK 7
Make any changes in your code, necessary to make it compile

Java GUI in NetBeans on Mac OS X 10.8

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.

Categories

Resources