How to specify which JRE to use in Netbeans? - netbeans

I have two JRE in my system. One is 32-bit and the other one 64-bit. In Eclipse I can configure both and choose which one to use when running my application.
I'm wondering if I can do the same thing in Netbeans. I've tried to go to Project Properties, Libraries and then tried to configure a new JRE there, through Manage Platforms, but it doesn't accept the directory of my JRE. How should I proceed?
Be aware that I'm talking about JRE, and not JDK ;)
EDIT: I managed to make it work by downloading a new 32-bit JDK and selecting its directory. I still couldn't make it accept a JRE directory.

Whether or not you can run Netbeans with just the JRE depends on what bundle you have downloaded. In Netbeans 7 only C/C++ and PHP bundles can be run with the JRE.
Older versions of Netbeans include more languages under this JRE umbrella, but the principle is the same.
The JDK contains the JRE plus tools to debug and compile code, so if you're doing anything Java based apart from just running the IDE, netbeans depends on the JDK.

Related

Automatically linking Java 8 source code with Eclipse IDE

In my installation of Eclipse IDE (Mars 4.5) it has not automatically linked rt.jar and jfxrt.jar to src.zip and javafx-src.zip. I know how to do this manually by browsing to the .zip files within the JDK installation.
What I want to know is if there is a way to ensure this happens automatically when installing Eclipse / Java. I'm pretty certain I know someone who didn't link to the source manually and it is linked on their installation.
For example, if you install the JDK before Eclipse, or vice-versa, does this make any difference?
Also, when you make the link, where abouts is the preference information stored on the file system - is it somewhere within the same folder that eclipse.exe exists?
To make sure that Eclipse is running in your JDK instead of a JRE (The JDK installation typically puts a JRE on the system executable path), you should always specify it via eclipse.ini. The -vm option described there tells Eclipse exactly what JVM you want it to run in.
Another option is to add the JDK to the Installed JREs section of your Eclipse preferences and set that as the default for all projects. The default JVM used for projects is the same as the one Eclipse itself runs in, so you don't necessarily need to do both.
Once you have the JDK set as the default JVM, you can open a project's Properties, select Java Build Path section, then look at the Libraries tab. You should see your JDK as the JRE System Library, including its rt.jar and corresponding source attachment. Like this:

How Do I make the Install4j IDE to upgrade to Java7 instead of Java6

I have upgraded to Java7 recently.
I had my install4j Project file in Java6.
Now in the Install4j IDE, I go to Media wizard and download 1.7 JRE's and select them for Windows. (I have window 7 64 bit.)
But When I go the Installer tab in IDE , where for some of the screens I have my custom code which is compiled in Java7.
It gives an error for the IDE java version lower than the compiled version(for those class files).
The Common Location where is the JRE for 1.6 was downloaded C:\Program Files\Common Files\i4j_jres
But the JREs for 1.7 somehow are never downloaded in the common location.
How Do I make the Install4j IDE to upgrade to Java7 instead of Java6.
Thanks
Sony
We had the same problem as you, so we just swapped out install4j's built-in JRE with the one we used to compile our custom code.
i.e. - replace "C:\Program Files\install4j5\jre" with the jre you use to build your custom actions.
Under General Settings->Java version, change the minimum version to 1.7

Is it possible to add a JRE to Installed JREs in Eclipse using relative path and Eclipse variables?

Is it possible to use Eclipse variables like ${workspace_loc} or ${eclipse_home} for adding a JRE to Installed JREs in the Eclipse preferences?
No, you cannot use variables for that, neither in the JRE preferences nor the execution environment specifications. And don't look at the eclipse.ini as suggested in comments, the JVM running your IDE has nothing to do with the JRE used to compile your project.
That said, there is still another easy solution (which we use in our company): Just install a second copy of the end user JVM at a known fixed location for your developers, so you can use that fixed path in the JRE preference page.
If you fear that the two JRE copies (in your project and at the fixed location) get out of sync over time, then you could use an Ant based builder to your Eclipse project, which conditionally copies the JRE from the workspace to the outside known fixed location during the build. But honestly, it does not really matter if those 2 copies get out of sync. If your code was compiled using a 32 bit JRE, it will run on another 32 bit JRE deployed at your customer anyway, as long as they are byte code compatible. And you can set that explicitly in the Java compiler settings of your Java project.

How do I bundle a Solaris JRE with install4j without running the install4j application on Solaris?

The JRE download wizard in install4j only offers Linux and Windows JREs. I need to build a media file that bundles a Solaris JRE. install4j supports building custom JRE bundles but it's JRE Bundle wizard states:
"Please note that the JRE Bundle wizard can only create JRE bundles
for the platform you're running on."
This seems like a serious omission as compared to the other multi-platform install buliders (i.e. InstallAnywhere and InstallBuilder) both of which provide bundled Solaris JREs.
Can I not just unzip/tar a Solaris JRE on my Linux build box and bundle it? Or is there a limitation of the mechanism used to bundle it?
Even though we support Solaris, Solaris boxes are in limited supply.
Can I not just unzip/tar a Solaris JRE on my Linux build box and bundle it?
You would have to create the tar.gz file for the bundle manually as explained here (at the bottom of the page).
However, I would rather suggest adding a requirement that Java is installed on the Solaris box. Bundling a JRE on Solaris is somewhat risky since particular JRE versions require certain OS patches.

How Can I Tell Eclipse to Compile and Build a Project with a Different JRE Version than it Normally Does?

I'm not sure if this question has been answered in full or if my title is descriptive enough given my situation, but I've been asked to convert a project from being built with Ant to Maven. That part isn't too bad, but I've been told that this application was designed specifically for the JRE version 1.5 rather than the JRE 6 everything else I've been dealing with uses. Now, I'm incredibly new to Eclipse and Java themselves, so I was a bit confused when I was asked to tell either Eclipse or Maven to build this particular project using the JRE 1.5 instead. I have it installed, I believe, and I've tried to follow the steps outlined here: ( Eclipse: Build and conform to different JRE versions ), but I've run into a snag.
I've managed to change the Run Configuration to use the Alternate JRE jre1.5.0_11. When I then tried to build it, the console spat out the following:
[ERROR] Unable to locate the Javac Compiler in:
[ERROR] C:\Program Files (x86)\Java\jre1.5.0_11\..\lib\tools.jar
[ERROR] Please ensure you are using JDK 1.4 or above and
[ERROR] not a JRE (the com.sun.tools.javac.Main class is required).
[ERROR] In most cases you can change the location of your Java
[ERROR] installation by setting the JAVA_HOME environment variable.
I assume this means that I need to be using the JDK 1.5 in order to use the JRE 1.5, since I'm currently working with JDK 1.6. Now, is there a way to install the JDK 1.5 so that this project can use it? My JAVA_HOME variable currently points to the JDK 1.6, and I would like it to stay that way... Is there a way to be able to use both and simply tell the project (or Eclipse or Maven... however it works) to use a specific version of the JDK?
Yes, this is possible. You can install as many different versions of Java — JREs and JDKs — as you like, and tell Eclipse which one to use for each project.
First step is to install the JDK 1.5 on your machine (JDK is short for 'Java [SE] Development Kit', look for that on the Oracle download site). The JDK includes a JRE, so to make life easier you can usually just install the JDK and not worry about the JRE/JDK distinction.
Second step is to tell Eclipse about the new JDK. Go to Preferences... then Java > Installed JREs. Click the Search... button and Eclipse should find your newly installed JDK 1.5 and add it to the list.
Final step is to allocate that JDK 1.5 to your project. Bring up the Properties menu for your project (right-click it). Then set these values:
Java Compiler tab
Tick Enable project specific settings
Set Compiler Compliance level to 1.5
Java Build Path tab, Libraries subtab
Find the JRE System Library item, click Edit...
Set Alternate JRE to your newly installed JDK 1.5
It looks like you are using JRE 1.5 rather than JDK 1.5
Make sure you download the JDK 1.5 and your issue should go away. You can set the default JDK in the preferences, search for 'jre'.
Projects can also define their specific jre
Get JDK 1.5 from Here http://www.oracle.com/technetwork/java/javasebusiness/downloads/java-archive-downloads-javase5-419410.html