|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE 5 @3 O* L- w" u. p% a
- G# E0 j! C5 V1 W. i
(see PDF in the ZIP file for a pictorial description)
: z& x7 t" |. N/ m$ z+ l$ g6 G2 v5 d& z* E
Installation of Java and Eclipse0 A8 g% S4 E+ W5 {, @
`1 G0 C0 T9 o- Y6 W: C( J4 J1)
3 ]" Z- ~; |- ~Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
& O5 b0 x! A. D* Z/ j% S; ahttp://www.oracle.com/technetwor ... ownloads/index.html
# N! Q% O- } q2 a; r7 @$ f9 S' @0 l. x- p0 f6 U, _3 ~
2)
, x5 b; J, \' ^$ YDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads
* a0 G, T3 q0 n7 E7 K/ |2 C8 Pand extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
/ l* b, ]. U+ X. ^4 `# C& n
! n$ `+ c: r/ M5 r# ]
5 X2 q+ ]8 O3 D C) ?8 N/ FCreate a project with Eclipse
- E8 E1 N% ?3 M* [/ H/ k% w# |1 }$ v3 K' k
3)8 \. @, R* i- M2 K* ^
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”/ o4 p' x' e2 `; A: Q+ W
& e/ V( n3 M0 t9 i: a* K
4). T1 H- P& g1 E% e$ G, B
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio. X: ^' x; P9 T4 C7 e% s- W/ V: M
+ B1 F9 k% ^4 f* d7 A4 I5)6 d+ \" f4 _1 J* }7 {$ e
Create a new Java Project by File -> New -> Java Project
1 w' d6 r- j' X- z1 O' I$ s* @( v' e! \% z* e
6)! u5 {# w* b. E# R1 e" |, ?9 B
Enter a project name and continue with Next7 n n2 Y% [3 V g8 N y& F
$ e" W K6 e: }: H [+ f- G7) ! s0 ]$ J/ p8 A# q3 q2 }
On the Libraries Tab add the external NXOpen Jar packages and Finish
% p) W/ _& E, y- L% l# ?% ?- ~' B' u! C& r6 }/ K3 u, {! \6 O C3 o; a1 g
8)
( t l8 r1 R% ?6 v6 E# _% nIn the Package Explorer window make a right click on the project name and create a new Package (Namespace) ( |# C& K. g% \" F; T% q
" E' w- I. d, Z" Q& E" |5 V4 w9)
! P9 V" a9 x% nEnter a package name and Finish
. p; I3 l: V3 H9 C
0 \: i: R, ^) E1 p( H3 l0 M( a) d10) B! z. q1 \0 i( \1 Z4 y+ [) y
In the Package Explorer window make a right click on the Package name and create a new Class
& I4 K% v7 V( t# _3 T8 y+ e
3 B, C, A& D5 F5 p u3 V11)' n% ~: B9 n% w, Y$ b/ A3 {( T. f
Enter a Class name and uncheck all method stubs options
1 _. h9 z8 K: u/ B% b/ @( Z0 Y
2 g( a+ o% A- w/ X6 S1 X' t12)
2 I$ f/ Y: _0 M' b5 jNow 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.
" d4 b9 e" S6 I' bFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java
h1 J# _9 r, L) A
& @1 _* \/ L6 S' Z13)' K0 R: y4 _: j& q5 Q
Start Recording by Tools -> Journal -> Record- k) l) _! J5 C% i- i
, x6 g B! [* t7 R& b" @
14) - n1 ^3 K5 V. ~( x' k
Create a Block and finish the journal by Tools -> Journal -> Stop Recording
/ l9 h0 A- w' h- d3 s) |6 t& ~% d. i& i0 ~4 s6 E. [ ~, J
15)) X; d y! b: e% a2 G
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
$ j2 o6 o6 U( A7 N! G, W0 [
1 K- f0 `/ @% ]! ?16)/ g9 L" i: K7 z; t
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
}6 d5 W( X+ p5 q9 u9 H9 }/ i+ P
5 T- V/ ]. T0 S- O) }17)
0 E2 v% ~$ s9 D+ PFinally we create the Jar file which is mandatory in case our package contains more than one class., E) E! P/ `! j' p3 K% W
In the Package Explorer right click on the project name and select Export -> JAR file -> Next
. L. a. C( p5 ^' o, J* j
; f, Y' n6 Y% K9 C+ f! S' v18)
. N/ O% F: S$ h$ DSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
0 U6 k4 K1 n. m& \8 | q9 Y; g6 ~) w1 `3 n; _1 |- v6 I, Q/ Y
19) _5 H$ e' \) V+ U0 k; _& `5 c
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
! _8 I! E) P$ t0 \, {
" n% E3 h1 |( O r2 U- b! k+ h) `. B
Debug the JAR or CLASS file with NX and Eclipse# B: i7 v* [2 z$ ~: j6 `
u" V4 Q5 v; E" Z0 f' p0 L
20)4 t& S6 s" |+ Q5 A
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 .
% O$ A4 Y3 L; B) }* V" xDue 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.
! ~' x9 D* Q* @2 g/ ?In 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.7 d/ [# F& ]+ e0 ]- x) a0 `6 ^
From a NX8 command prompt, we enter the following commands:/ T; b, F4 m% a3 L8 v' B6 w+ q
R( S3 ]% l2 k
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n* y6 w: G' O* o) r; j# F# E* J4 N
>ugraf.exe
- `3 C! M% h$ l3 M% n0 |
; ~# ?+ M* R0 v6 bThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
\7 f9 C/ A$ O8 u9 ?# T aAny simple class will do the job, for example a famous HelloWorld class.
0 Y, }# g2 R; Q X+ |( n! |) U' m, y: ]+ i/ X
21)
% F; x% `9 B! Z0 y# kCreate the external access to the JVM session in Eclipse by Run -> Debug Configuration.4 H! y' M: s- _' q2 _5 j
On the Remote Java Application node make a right click and select New
5 d% }. N2 S) U9 Q
) x$ O" j" y8 c* g# k2 E22)0 v% u# G2 i+ g
Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
! F& M8 W* L6 e( A5 T4 a! B( U
! Y) r1 K F# M4 f2 Z& N23)
; L2 V& N( b0 O" L# B* o% j4 kDon’t forget to set one or more breakpoints in your code where you want to interrupt execution
* }7 o6 W6 x) u/ G
; k8 f: q5 O8 ?! M6 o, Y! D24)) n/ p4 O) p, a2 z' Y
Finally execute the JAR file or CLASS file in NX that you want to debug.
# _2 D% m: h* o; E( |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./ ~( p! b1 c9 D2 A1 e) Z
9 [2 p8 V! [1 x6 SThat's it.1 Q: g+ N- @" y* |
|
|