|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE / F" ]7 Z* V- e T9 q
6 i9 O( [0 _! l& R% G- D; a
(see PDF in the ZIP file for a pictorial description)
& \: ]; N; K6 Q$ \+ r% s
( m& I% l& ^9 \8 e" d5 x; DInstallation of Java and Eclipse
8 k' b: g2 U0 O! S5 d; n" I4 e& B0 m& m/ ~( r3 K l
1)5 K+ }9 N6 r2 i
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from0 o& l; m) P: e t8 h+ g8 O, d
http://www.oracle.com/technetwor ... ownloads/index.html
/ J7 E4 @ P# H5 Y. m$ J' E" y2 H# }$ L. Y4 H4 x% n0 C
2): ^% b* y. l" o, F8 O* J, | @. U
Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads 5 E& {% e$ ?# Q! d
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
9 J! \7 V1 o+ D" D* J- o `0 r4 e+ ~
+ h1 E6 P9 n9 A8 r' H Y6 F) X, h7 b9 j( K
Create a project with Eclipse
$ r+ z8 n3 h9 o( R
/ @8 }8 @+ P3 Y( k/ b) K5 P0 U$ x3)
, g; `# M& Y, N4 xStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”- ~1 N! S( n- O/ f6 U) J$ ~/ A
' ^- y3 l+ T1 u* r# x" {, I# B2 Z1 q4)
9 O$ _4 r9 G- g% f4 DYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
( f4 K2 B- N4 h! M9 H- S, R d) C9 n" @& n P9 o: x7 o
5)
5 c: B& V1 ~# Y! GCreate a new Java Project by File -> New -> Java Project
& c0 J; O" N9 I9 |: C6 g
" N. U* ]8 A) z& u1 M9 J. V2 H6), k' t* i Z; E9 V" |3 p
Enter a project name and continue with Next
: c; Z( I3 V( X$ S9 C, v; ?9 }. h9 d( \9 r1 [8 G+ t
7) 2 Q4 R; n+ A& ]3 j
On the Libraries Tab add the external NXOpen Jar packages and Finish
9 j/ V/ W+ d( _1 S5 T
2 }7 a; |, b/ B5 x* v8)
8 Q% `# x6 L/ i& |. MIn the Package Explorer window make a right click on the project name and create a new Package (Namespace)
& K( z: {( X+ K n( {
2 [" h/ ~7 ?% F- N# _5 X- ]3 A% I9) 0 H% ` A2 q3 o
Enter a package name and Finish9 a* R! O: \+ D& w: ]! O2 X
4 e9 n* }; ]: n6 j/ Y" O! u* V. B10)
( F! F! P2 h, EIn the Package Explorer window make a right click on the Package name and create a new Class 2 w3 y+ ^ I$ f
+ l+ E: m9 M" g& h; f6 h11)
% K7 S4 x, F6 H# wEnter a Class name and uncheck all method stubs options. P- K6 w. [0 B6 X1 z
6 ?: Q/ t6 G, h+ O
12)
: J& p9 W6 ^5 L7 J7 B6 k& G# LNow 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.. t4 r. f: }# F* q6 u
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java
2 T9 } z! g( P8 u: H
- h% ]6 a! I* a. x3 k13)6 q$ ^' q7 ^0 W( z2 N8 Q. g
Start Recording by Tools -> Journal -> Record8 G1 h/ Q* u# C* u. L: _
2 u# {0 _: T q" W9 w14)
4 A; @' _6 i) F: U+ a, b ACreate a Block and finish the journal by Tools -> Journal -> Stop Recording
: x. V4 Q6 X# S! k$ U5 r4 B4 N2 ^
15). {3 d% c, H/ x
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
. F# X+ F2 L @6 g! n1 ]9 T. I; w1 A0 x& n5 d7 [
16)8 L" N7 _- c9 j$ Y- Z& Z
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”# n# {; k' m+ z2 M; n6 i" h
0 {4 a" a4 G. S- N5 b/ Z7 a1 @17)
( s, W# b( }2 |. i7 ZFinally we create the Jar file which is mandatory in case our package contains more than one class.
5 j$ a4 s' Q- [" @; O4 s6 A5 t& G- p6 FIn the Package Explorer right click on the project name and select Export -> JAR file -> Next# h2 k& j$ s3 F9 K
# O* h; u& f5 H% w+ L
18)& g& n& p+ q' w
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
: o0 q% M- {: B2 d% n/ k' z7 D
) b. p( s4 @: t' U# W, U19)" i4 o( [8 I" x' e3 E8 V5 p7 v
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
7 q8 a/ ?' N5 m n0 \% K) ~/ b9 [4 ~" E; Y
4 _+ C3 Y2 S+ V; p
Debug the JAR or CLASS file with NX and Eclipse
5 Q3 k# L. {0 r/ E
3 m$ J7 M6 R; c% ]# C% y20)
& t8 |$ R1 i ]4 ?# kIf 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 .( }4 e/ Z" b2 h& |9 H) t: G$ e
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./ _2 X6 p: c* i
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.
5 @: L) R' a, \& Z/ J2 | |From a NX8 command prompt, we enter the following commands:/ P7 T! F$ S' x; p w
* o% [6 M$ D, i6 Z: o) p>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
- Z0 M8 A2 s2 {/ J) E>ugraf.exe
X+ T4 v0 G8 |+ q8 g% y( M+ t
& O9 ^6 R3 P T. v7 h2 zThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
' k, e2 `# j0 Z4 E8 K! a2 T: ?Any simple class will do the job, for example a famous HelloWorld class.- _; Y/ {. S, y4 h
( V; E G# ], ]: i6 {/ ?6 Y
21)- Y* s7 p) [5 d e& A( I) U
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.: x4 t& \+ h _5 C( X9 g
On the Remote Java Application node make a right click and select New / f2 K; t! k# P' N+ R2 J+ B: c/ U
; l7 c" A- p' o r) L# z
22)
! r# C/ L, y% aEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS" U, l# n6 G. y' T% V1 `
/ q( `2 Q H' _" m' }3 M. V6 q% V23)+ Q# m' }+ r/ v; N% M z
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
/ z' I$ E: S* [4 p, f# n/ V5 w' F) f0 m; D9 t a
24)+ }7 B8 ?8 \1 N0 Z0 w
Finally execute the JAR file or CLASS file in NX that you want to debug.
& s) z% ?* [4 t4 l* Q& f0 P7 ^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. _9 Q! u# t( G8 y+ S1 v
" k0 o- `" C8 P+ }* T# M1 `) pThat's it.
; j# j- S$ U% h& W |
|