Book a Demo

Author Topic: Importing Java API classes  (Read 5800 times)

uther

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Importing Java API classes
« on: June 08, 2010, 05:39:42 am »
Hello,
I'm just wondering if it is possible to import somehow into EA java classes like core JDK classes etc. so I could choose in class diagram designer for example which interface from JDK I want to implement, what would be class's superclass (for example JFrame) and I would like if when I let EA generate my code that it would create imports for me automatically.
I hope it is possible, thanks for any answers

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Importing Java API classes
« Reply #1 on: June 08, 2010, 09:05:00 am »
Look at Project | Source Code Engineering | Import Binary Module.

Import the appropriate jar file, then set aside/delete parts that will only get in your way.

Aaron B

  • EA Administrator
  • EA User
  • *****
  • Posts: 941
  • Karma: +18/-0
    • View Profile
Re: Importing Java API classes
« Reply #2 on: June 08, 2010, 09:56:55 am »
In addition to Simon's comments - Another method is to extract the required .class files from your jar file to a temporary directory (most zip utilities support opening jar files) and then import use Project | Source Code Engineering | Import Source Directory.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: Importing Java API classes
« Reply #3 on: June 08, 2010, 07:11:39 pm »
Did you start from the context menu of your package?

Geert

uther

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Importing Java API classes
« Reply #4 on: June 08, 2010, 07:13:45 pm »
Thank you for your helpful replies.
I'm almost there, there is just one more problem left - I've imported required classes but I just can't figure out how to make those imports top level, I mean it was possible to import those into MyClassDiagram package, but not into Model i.e. root node of the project so when I generate my code, there are imports like import Model.java.io.XXX;
Any leads?

uther

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Importing Java API classes
« Reply #5 on: June 08, 2010, 07:18:17 pm »
Quote
Did you start from the context menu of your package?

Geert

Sorry for deleting my post I thought that I made something wrong and had a fix whichm I dont have..
Anyway it doesn't seem that there is any choice in my Model's context menu, I've imported Java library clases from Project menu and to do so, I've been forced to use it on diagram as Binary  import was disabled when Model in Model inspector was selected.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 8110
  • Karma: +119/-20
    • View Profile
Re: Importing Java API classes
« Reply #6 on: June 09, 2010, 08:25:27 am »
Right click on the package 'Model' and set it as a namespace root.  You can't do any code imports directly under a root node because EA doesn't allow classes directly under a root node and an import can create classes immediately under the selected package.

uther

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: Importing Java API classes
« Reply #7 on: June 10, 2010, 01:46:21 am »
Thank you that was exactly what I've been looking for, now everything works just great for me.