How can I get the “Eclipse >Generate>Jaxb classes”

2019-01-23 11:25发布

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.

9条回答
forever°为你锁心
2楼-- · 2019-01-23 11:34

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

查看更多
forever°为你锁心
3楼-- · 2019-01-23 11:35

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.

查看更多
beautiful°
4楼-- · 2019-01-23 11:38

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.

查看更多
▲ chillily
5楼-- · 2019-01-23 11:44

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.

查看更多
劫难
6楼-- · 2019-01-23 11:49

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.

查看更多
Ridiculous、
7楼-- · 2019-01-23 11:50

(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.

查看更多
登录 后发表回答