How can I get the "Eclipse >Generate>Jaxb classes" option back? - java

I recently had to migrate to a new machine and re-installed Eclipse.
At the moment, I need to generate JAXB classes from an xsd. I cannot quite remember what I installed, but in my old Eclipse I had the option -rightclick-generate-jaxb classes.
Who knows what I have to install/plug-in to get it back?
I was looking at installing Dali, which seems like it could be right, but I am pretty sure I did not install Dali last time. I also included the jaxb jars in my build path, as last time, so that should be ok.
I am using Eclipse 3.6 and Java SE 1.6.

If you don't have JavaEE:
Help>>Install New Software>>Works with:--All Available Sites--
Search for JAXB
Then select Web, XML, Java EE and OSGi Enterprise Development and install.
After you restart Eclipse you should see the generate option.

A simple fix for this problem - rather than worrying about adding additional plugins or installs - is to install Eclipse IDE for Java EE Developers rather than Eclipse Classic (both to be found here). This comes with the JAXB support and therefore provides the >Generate>Jaxb classes option.

The above methods may work, but actually the options comes from a plugin called Web Tools Platform which comes along with Eclipse IDE for Java EE Developers.
Don't worry about reinstalling eclipse or try out other methods. No matter what eclipse you use simply install this plugin by following the below procedure. You will get the "JAXB Classes" Option on click of "Generate" button.
Help --> Install New Software --> Add
Name : Web Tools Platform
Location : http://download.eclipse.org/webtools/repository/helios
Hint : In case if you are using a different version replace helios with your eclipse version name. I used it as luna. So the path looks like http://download.eclipse.org/webtools/repository/luna
And restart eclipse. Now you will have that option.

(I'm using IBM's Eclipse-based RAD, so I don't know whether this applies to raw Eclipse.)
Have a look at your project Facets (select project, rightClick->Properties, Project Facets) I have the option of selecting JAX/RS.
later: I've checked my plugins and by default I get Dali installed and it does contain some JAX/B-related stuff. I suspect you do need this.

After a lot of research here is what I have done to fix the issue.
Windows> Preferences> Java> InstalledJREs...make sure to point your jre to the jdk directory. I was pointing to JRE and as soon as I changed it to JDK, it started working.
Hope this will help you guys.

I installed this plugin
http://java.net/downloads/jaxb-workshop/IDE%20plugins/jaxbw-plugin.zip
i.e. unzip and copy to eclipse/plugin folder.
It adds an entry "JAXB 2.1 > Run XJC" to the context menu of *.xsd files.
So the menu's not really in the proper place, but it works.

In order to support the standard JAXB APIs in the IntelliJ IDEA Community Edition environment, you need to make some adjustments. One way to implement JAXB technology is to connect the xjc.exe utility included in the JDK toolkit. This utility can be launched at the command prompt, but it is advisable to configure the context menu:
In the Settings window, select Tools | External Tools and press the
"+" button.
In the Edit Toolbox dialog enter:
the name (Name :) of the new Generate JAXB Classes command;
the path to the xjc.exe utility (Program :), which should be selected on the particular computer in the file selection dialog(button "..." )`
parameters (Parameters :) which in our case will be as follows:
$ p $ FileFQPackage $ $ SourcepathEntry $ $ FilePath $
In order for the created command to work correctly, the schema file should be placed in a new package, which will then appear with the generated files.
In the settings window, Tools | External Tools - "Your command name" will appear.
All you need is to open your schema file and run the command.

you may download JAXB Eclipse Plug-In
jaxb eclipse plugin

I had the same issue while attempting to generate java classes from xsd file.
My installed Eclipse is:
Eclipse Java EE IDE for Web Developers
Version: Oxygen.3a Release (4.7.3a)
Build id: 20180405-1200
I solved it changing the workspace default JRE from JRE to JDK in Project Properties / Java Build Path / Libraries
This link describes how the problem arises:
https://www.youtube.com/watch?v=zgblFjA-5Ks
This link explains how to change the default JRE.
https://www.zkoss.org/wiki/Setting_Default_JRE_In_Eclipse
Hope this helps

If you're using Eclipse EE all you have to do is switch your running environment from JRE to JDK and that should fix it. Windows -> Preference -> Java -> Installed JRE -> Add - > (Choose Standard VM) Then Select JDK!
Then Execution Environments under Installed JRE select your JavaSE-1.8 or your version and also select JDK!

Related

Impact of Eclipse version on Code version

Does the version of Eclipse affect the version of code? Suppose, developers are using different version of Eclipse for same version of code with same version of JDK. Will it cause any issue?
No, the version of Eclipse does not matter.
Eclipse has extensive configuration for exactly which version of Java you are targeting. For example see the 'Java > Compiler' settings in the Preferences, and the 'Compiler Settings' in the Properties for a Java project.
You can also tell Eclipse which JRE/JDKs you have installed (see the 'Java > Installed JREs' page in the Preferences). You can run your code using any of these JREs, this is completely separate from the version of Java you are using the run Eclipse itself.
You do need to run a version of Eclipse which understands the version of Java you want to use. So for Java 13 you need to use at lease Eclipse 2019-12.
Of course newer versions of Eclipse contain more tools for helping with Java development and more bug fixes so using an up to date version is recommeneded.
Eclipse is simply an IDE (Integrated development environment). It combines debugging, compiling and other convenient tools for development. on the other hand, the Java code itself is separate, and you don't necessarily need eclipse to write the code. In fact, a simple text editor is enough. All you need is a file with a java extension (Example: hello.java).
It depends on what users share. I'm assuming you're using some sort of SCM, in which case the same project (fully shared) on different versions of the IDE can possibly lead to annoying situations.
There would be no issues in general, as far as producing the code is concerned, except in situations where some versions of IDEs don't support the required Java version (or other features). But I see this more as the user being affected rather than the project/code.
Here's what you should keep in mind:
Keep IDE project configuration files (such as .project, .settings, .classpath) ignored by your SCM system
All Java configuration should be based on a build tool. Use Maven/Gradle, etc, and any modern IDE will be able to create a project from its config file. The IDE would derive local configuration files which should not be sent back to shared repositories
This way, all developers are free to use whatever IDE (and whatever version) without causing interference, and CI tools will work off build tools' configuration as well.

Create a distributable Eclipse bundle on MacOS

our company uses the Eclipse IDE with some plugins that are required to start our platform. I want to create a bundle for our Java developers that contains the latest Eclipse Java (Oxygen) with the plugins already installed.
So far I've installed Eclipse with
sudo cask brew install eclipse-java
which created an /Application/Eclipse Java.app.
After installing the plugins within Eclipse with Help->Install New Software the ~/.eclipse/ was created in my home directory.
Is there some way to zip these folders to create an distributable package of eclipse or am I missing other files/directories?
Is it possible to move the plugins in the installation directory as well?
Thanks for your help!
It is not advisable to use any Eclipse distribution that's produced by packaging tools. It's best to download directly from eclipse.org, for various reasons.
As for customizing an Eclipse "package" for distribution yourself, have a look at the Oomph project, which is designed for that exact purpose (and others). Oomph is what produces both the installer and the downloadable packages of Eclipse IDE releases. You can read specifically about Oomph authoring here.
You can use the official eclipse installer. There is an advanced mode to disable the p2 pooling. Then using this mode, everything will go into the eclipse folder. Afterwards you can zip it and give it to others. Of course you are always bound to the CPU Arch still.

Install e(fx)eclipse in Eclipse Mars

I tried to install e(fx)eclipse tools in Eclipse Mars but it not successful and show that message when I start Eclipse:
You are not running your eclipse instance with Java8. The JavaFX tooling is disabled because of this.Make Java8 the default system java or adjust your eclipse.ini to pass -vm pointing to your Java8 install.
In case you want to turn off this check open your preferences and go to General > Startup and Shutdown and uncheck 'JavaFX Tooling Java Check"
Could anyone help me about this?
As stated an update might be everything you need. I had a similar issue under Linux once, where there were two JVMs installed and the older one was in the projects build path.
You can check under the projects properties -> java build path if Java 1.8 is shown there.
Regarding tools: I don't think you'll need any. Try and get familiar with the JavaFX Scene Builder. It makes building a simple GUI super easy.

Which Java is Eclipse using?

I downloaded 'Eclipse IDE for Java EE Developers' for Linux from eclipse.org. I am able to write, compile and run Java programs. But I don't understand what JDK / JRE is being used.
If I start a new 'Java Project' I can choose which JRE to use, but if I choose for instance 'JavaSE-1.6' I still don't know what that is? Oracle? IBM? And I don't know where that JRE is in my file system.
Let's say I want to use that same JRE to execute my Java program from command line, how do I find the 'java' executable?
While you are in Eclipse:
Open Help -> About Eclipse
click on Installation Details
select the Tab Configuration
search for the entry
eclipse.vm=
there should be the path to the used JRE.
If you want to know where is Java located in you'r system, run it in terminal whereis java.
If you want to know which Java is using in you'r system, run it in terminal which java.
If you want to know what is Java version is using in default, run it in terminal java --version
If you want to know which JDK is using in Eclipse,Refer to Project->Properties->Java Compiler.
If you want to know which JRE is using in Eclipse,Refer to windows->preferences->Installed JREs
It is up to your configuration.
Go to Windows/Preferences, then check:
Java/Installed JREs and Java/Compiler/
You can also override your settings per project: project preferences, Java Compiler.
(this is too long for a comment)
Let say I want to use that same JRE to execute my Java program from
command line, how do I find the 'java' executable?
On Linux the java executable is the first executable named "java" found on your path.
For example:
... $ echo $PATH
/home/f/jdk1.6.0_33/bin:/usr/local/bin:/usr/bin:/bin
... $ which java
/home/f/jdk1.6.0_33/bin/java
You can install as many JRE/JDK as you want. You can even trivially create user accounts with Java (e.g. a user account for development) and users account without Java (e.g. a user account without Java that you'd use only for browsing the Web [see comment]).
If you try to launch Eclipse when the $PATH doesn't contain any Java executable and if you didn't install any JRE/JDK inside ~/eclipse/, then Eclipse shall complain and refuse to launch:
"A JRE or JDK must installed in order to launch Eclipse"
At that point and if you did install Java, you can simply add it to the $PATH and Eclipse shall launch:
... $ export PATH=~/jdk1.6.0_33/bin:$PATH
Eclipse gives you an option to select the JDK on per project basis as well as for All projects.
For All projects :
Windows ---> Preferences ---> Java Compiler ---> Compiler compliance level ---> Select the JDK you wish to work with.
For Specific projects :
Project ---> Properties ---> Java Compiler ---> Compiler compliance level ---> Select the JDK you wish to work with.
The settings for the specific project is given priority over the All project settings...

Schema missing from eclipse plugin environment

I am getting this in my plugin perspective. I get a generic menu istead of specific items e.g. action, etc.
(source: sourceforge.net)
My "Preferences / Plugin development / Target platform" looks like :
(source: sourceforge.net)
When I go to edit it looks like :
Is this similar to this thread?
I just figured out what was the problem.
I was using an external target platform to run my plugins, where I had installed only the basic plugins.
After I installed the sources org.eclipse.platform.source_2.1.0 and org.eclipse.platform.win32.source_2.1.0 also on the target platform, the manifest editor in the PDE was working normal again.
(to be adapted to your Eclipse version)
Also confirmed in this more recent thread:
Your target platform (and the default will be your own eclipse install) needs to have the source bundles (which provide the schema files used by these menus).
i.e. if I installed the runtime version, I will only get Generic in the menus but if I install the SDK version I will get real elements.
Thank you very much for the answer.
I "Add" source file to the platform (Preferences / Plugin development / Target platform) and got all menus!!

Categories