PLM之家PLMHome-国产软件践行者

[原创] 使用eclipse进行NX二次开发的设置步骤

[复制链接]

2015-2-25 13:02:01 4658 0

admin 发表于 2015-2-25 13:02:01 |阅读模式

admin 楼主

2015-2-25 13:02:01

请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!

您需要 登录 才可以下载或查看,没有账号?注册

x
DebUGging NXOpen Java with NX8 and Eclipse IDE " B4 m- n  a& ]1 T  l3 A6 T$ a, E) G

- W$ M7 g$ K1 I; i, d  e7 O$ w' G(see PDF in the ZIP file for a pictorial description); Z- S0 @# j' C/ x. L: V
6 q0 J# R/ I1 i& E% Y
Installation of Java and Eclipse3 ^" d! ^4 M' p: Y2 m
8 C2 g% i9 x5 K; B
1)" f$ f$ e. W& u/ R8 M* P2 p7 O
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from7 ^: K* n; |# a% j9 l* z1 v) v8 Y
http://www.oracle.com/technetwor ... ownloads/index.html : \& |$ p. H$ [" O
" S3 _9 ]- q4 }* Y. [
2)
3 i- y2 ~2 O& j& c3 Y# dDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads
# p& w3 b" l; w+ P, i6 v0 L" Eand extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”' x- p. `6 F3 p. R2 w6 u7 K
4 |4 d' R, s& }9 ?2 [* e' X

9 R  V) k7 n- i1 Z* g( |( {2 jCreate a project with Eclipse   
5 u9 P+ r8 y8 H' x/ P2 {5 x3 L$ A6 h- x' S! X; D3 F- G: l
3); V8 t$ ], W2 _! a) ?- O
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”/ l( F0 |, O( {$ q3 z  U- \5 H( S# s
8 |! ]8 r# o( o/ M& k; k6 J9 r, e
4)+ Z; l, k0 e5 Q! l
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio& w8 k! X: L) Y" S, S' s

5 t8 v+ y/ M2 K2 P. n( |5)
/ [3 U' q+ B& e& F. G, x; WCreate a new Java Project by File -> New -> Java Project7 m) b- T4 u3 X+ E0 v/ D
" L4 p5 N0 T- q! j% b4 d7 Q
6)2 V  [7 i4 ^; o& _7 a
Enter a project name and continue with Next# l! [; \6 w" K/ u

1 D! K! A& r) r; l7)
8 |$ ^7 C& m5 \, F4 S) qOn the Libraries Tab add the external NXOpen Jar packages and Finish
$ C  \- M) ?5 p* l1 ~, z' q  I% Y* |$ G! q  ~0 i  J
8)
) ~. }- X; ]  {+ @; x* c$ dIn the Package Explorer window make a right click on the project name and create a new Package (Namespace)  
' _# @9 h- }- `8 D! e7 d7 h4 ^3 b, J: L: g/ W
9) 4 o# E# R' w1 t, N& s/ @  v, E: A4 R
Enter a package name and Finish
  V* X: i2 g: F) f' {7 K2 i: k, J/ r4 N% M& B: T% ]
10)
' I+ c* h* O8 l& Z% }( q8 lIn the Package Explorer window make a right click on the Package name and create a new Class    2 j; R2 ^0 a" ]
6 {3 @$ t# i1 y* }" ~* A* z
11)& P1 y9 b  H0 f8 K8 ?
Enter a Class name and uncheck all method stubs options
, n$ @. U8 N" G7 b
" h7 `  O0 N8 R12)/ p" A5 b; B- ^6 u1 K4 k
Now you have a project created with an empty class so it’s time to complete the source code and we use the NX Journal Recording.
% j+ b+ c: |! f* \$ `& R# xFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java. U% S: Z" V9 [7 _
0 }; I7 {. l: T2 A. i' q. ~
13)
+ X. v# z3 A' XStart Recording by Tools -> Journal -> Record
2 P( A0 c0 O$ p: i5 T$ d6 T+ P# q% ?( x$ N8 X
14)
4 t" i6 G- y5 ~$ I0 m! `. I# CCreate a Block and finish the journal by Tools -> Journal -> Stop Recording
3 D# p" \3 ^! C+ J+ K  m6 k
7 a  R! q$ P( A5 x& b) H15)7 \9 M, e" x% b0 b, N& P
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file+ h& ~& w+ v$ I& k

/ u5 q3 T0 {5 t$ M8 J9 Y# u16)% ?8 ~; A8 U" V' p" w: h* B0 u
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
0 ?, D! T4 Q7 E: u2 x9 x& y9 i( S+ ~, p1 G" e
17)
6 n; x& I" `/ g7 |2 d3 w9 N  XFinally we create the Jar file which is mandatory in case our package contains more than one class.
7 g; L8 ~! p8 u0 I7 KIn the Package Explorer right click on the project name and select Export -> JAR file -> Next7 _# D. D8 _1 u) F, J9 v8 z  k
8 _1 y7 C* k+ h
18)% q& `. G! B& D% ^6 o+ M
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
: U1 @% I! b# s/ ]0 |+ c% ?0 o3 m* Z. x$ }
19)# n  D% L6 S- a
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish+ |# ?; B* u( G- Q6 J7 S% f
+ P, F  \- `& S' a) {2 E( y" a
4 \+ _+ Z$ |# G' M6 L( ?0 p
Debug the JAR or CLASS file with NX and Eclipse, j+ t& i! j1 J- O
1 h& c; E, E3 i- R( c  L' O
20)" B! K0 Y( {6 I# c3 h
If we want to debug a single class only, we could use the compiled Java class file which can be found automatically after saving the Java source file in workspace\projectname\bin\packagename\class .$ l* M$ g; F3 C! p# C0 u
Due to Java naming convention and limitations we don’t want to have multiple classes in one file so in that case we would use the final JAR archive file.
. S0 \( a1 w4 n- r: gIn order to connect to the NX session, NX needs to start the JVM (Java Virtual Machine) along with some debug settings, for example the communication port between NX and Eclipse.. K7 ]9 S; J& j& V
From a NX8 command prompt, we enter the following commands:
( k3 I3 _4 L- ^# N
6 y& B% t1 [! ^" g" ?>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
$ m: ?3 Y! f/ i9 }/ K. h>ugraf.exe
& J/ h: M8 D2 Y. N) ]- U
; @6 A( R1 n* z+ \Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.! S$ k% p9 w+ t- k
Any simple class will do the job, for example a famous HelloWorld class.1 w" Q2 i" U: o: n

; f2 h( Q9 K' ?5 C: ~$ K21)
. i5 r  E1 }7 DCreate the external access to the JVM session in Eclipse by Run -> Debug Configuration.
) ~& ~5 K+ k( lOn the Remote Java Application node make a right click and select New
8 ?. Y7 T  n1 H* b
& b- R$ e4 Z" j& ]22)
8 J( ?& m! r" Z7 `Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
+ H0 [- ^8 |. Y8 D4 l( W
! ]* X$ R+ T1 [8 ]* Q23)/ s: T9 W2 S2 v
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution3 N; n/ G4 F$ |3 @* o* v; X) F5 D' }
. s6 {6 y, _: ^; r3 f: ^2 r
24)
7 b/ a6 F4 U' X, cFinally execute the JAR file or CLASS file in NX that you want to debug.! [1 U* W0 A; A9 Y: C
Once the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.. r9 p  q( ?% ^; |5 B  r
/ g- ?; L+ n  \' q7 }; y
That's it.
6 k( n, v- d: P  O3 y& G6 I
上海点团信息科技有限公司,承接UG NX,CATIA,CREO,Solidworks 等CAx软件,Teamcenter,3D Experience等PLM软件,工业4.0数字化软件的实施\二次开发\培训相关业务,详情QQ 939801026 Tel 18301858168 网址 www.diantuankj.com/ doTeam.tech
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 注册

返回列表 本版积分规则

  • 发布新帖

  • 在线客服

  • 微信

  • 客户端

  • 返回顶部

  • x
    温馨提示

    本网站(plmhome.com)为PLM之家工业软件学习官网站

    展示的视频材料全部免费,需要高清和特殊技术支持请联系 QQ: 939801026

    PLM之家NX CAM二次开发专题模块培训报名开始啦

    我知道了