|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
×
DebUGging NXOpen Java with NX8 and Eclipse IDE / G, \* i( P; W4 s( }+ \
0 p& C, B- F8 _1 B1 F! f7 m* _# X- g(see PDF in the ZIP file for a pictorial description)
, q. Z9 F! n+ ^. n/ D% s+ C, u9 [8 f/ X
Installation of Java and Eclipse
$ G9 m) u! f. w% _9 n; q# u" d( L# X, h0 E% X+ Y; Q9 W. N% S
1)
8 ^: O9 K# ]8 P0 L' _+ V, T$ dDownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
4 l2 O3 j$ |$ u/ ~ c( ?/ Y7 bhttp://www.oracle.com/technetwor ... ownloads/index.html 0 k' _" A4 m% \% S
& i- B) A5 A; }# g6 @0 p3 L4 b2)8 \6 Q- ?5 G' [' {' V) k
Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads
' ]6 m! d1 K. p, T! @0 \. l9 Hand extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”7 P0 u4 M. d' o% P7 T% u1 O% J
2 s) ?5 \/ s: B$ U4 O7 f
$ k, Z+ P) [& j2 Y
Create a project with Eclipse 5 `' R6 D4 b* U( N4 M
# }* g/ [7 `1 p. T! Y: |, ^& W3)' u' \4 u3 h0 H1 c7 y
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
. U' _" {9 d, R1 h. w; r$ b+ K; b3 \- y
4)+ S- k8 W0 b$ g4 E0 s" \, m
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
5 B2 z& q5 B% x" h7 F$ d! T: Z |1 V' B/ M: ?: W3 r
5)
) G1 M4 F/ n' F! w: s0 ]5 A/ ?Create a new Java Project by File -> New -> Java Project
8 c5 \! J$ _8 _# s# d% ?
$ y/ m+ W* t% K0 y6)
Z' n, E9 H1 Y8 }/ cEnter a project name and continue with Next
! k6 n- v' W" D( F: O# [! ]% X |& V0 n; C7 b; U; V: ]5 f
7)
7 p! j2 {6 Y, ? t; T& gOn the Libraries Tab add the external NXOpen Jar packages and Finish- Y2 E+ F8 T* V( S; w9 Z2 n
( l) g: [1 Z4 `$ q! r! O4 f8 D. d8)
( Q* ^# K" I; a* J$ V& xIn the Package Explorer window make a right click on the project name and create a new Package (Namespace) ; ~& G6 ]. n8 R% [
' A* Q( O. p' l, b# @1 j3 T
9) 4 O' B Q3 I, w
Enter a package name and Finish- c# G/ i! S' D' F. y4 w
+ D2 |1 u; ]" R% W; d8 ~. P10)
" g5 R: m4 o$ o) W* P# WIn the Package Explorer window make a right click on the Package name and create a new Class : C4 }3 Q, {: r- ?
2 e# I _, l2 l# r# p0 t5 o% t11)
6 Y# p: ~1 e( e2 }9 J2 \Enter a Class name and uncheck all method stubs options r6 M) x8 j1 n+ T& L% m
% ~( ?+ p9 [, j, s6 Q# L12)2 f$ b9 ^# P [
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.
2 S( N u; w4 N3 G# h: A) lFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java
( U! o2 u7 d5 i" e& c0 y
; ]( I8 k z/ K. m( d' ~13)
j, q$ a7 o; h$ YStart Recording by Tools -> Journal -> Record
' v$ _6 k/ d0 ?) [! Z" p0 o0 N0 l1 s) m6 G7 ?" _
14) 4 M0 R9 G( A* U1 p. t' g( s
Create a Block and finish the journal by Tools -> Journal -> Stop Recording
- h8 |% Y' }: T+ n k9 D& a; w# Z* t" }: A6 H
15)
- N# X8 i4 B* H6 `$ mOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file3 y7 Z1 p7 c$ _2 I9 B# K( a& h& \
4 d6 A q2 j2 K6 Y" A5 k" u( I- d16)
- ^6 K9 x* e0 W% n3 j* n* [+ `: HMake a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules” ]* |- O% c* S0 x
5 O& v+ u. S4 l5 H& H2 C. k17)6 q; R; e3 ?. |* j
Finally we create the Jar file which is mandatory in case our package contains more than one class.
0 _0 N/ [0 t4 U7 VIn the Package Explorer right click on the project name and select Export -> JAR file -> Next
$ v* ?! _$ @( C. R" J) i
# S. \- M h2 i' ?8 ^. e+ @18)
- ~) R& V8 R2 E' u; aSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
1 I4 f8 g# b0 i* M" D- X# N7 j
0 [4 S0 ~- N$ n! Y& _ o19)* f5 H# W, U3 `
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
2 f( W. S8 s. C" H* J3 ^+ ^. w$ [
3 U8 S+ ~2 |# ]3 L7 _8 t/ T/ ~" ~" a- ]$ Y
Debug the JAR or CLASS file with NX and Eclipse
7 U: ?. B Q$ p. ?
& B- h9 D; L" g! U V4 D20)
9 R- r! [& a; h- V6 U* y# _9 w" ZIf 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 .
* U( c3 U6 ]$ ZDue 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., _$ H/ j5 W% e: ?: c% S% N$ Y
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.
8 a* b6 X5 @$ [; LFrom a NX8 command prompt, we enter the following commands:* v$ Q: K4 y8 ]6 e( \& ~/ g" z% K
, d, f+ I6 h1 [7 a4 I>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n2 U5 i$ t- N! x9 M3 _' u
>ugraf.exe
( { J Q( n$ K* d3 _# M# a" ~% w' Y/ k+ g& n! E# F8 A6 a
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
4 z% j. U& N8 Y1 f2 cAny simple class will do the job, for example a famous HelloWorld class.8 n$ p L/ w2 N' g8 |# g
, n+ d9 t% e: ^
21)1 N4 s$ l( C, n# X) h$ f
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.
! C( S; A2 [4 L5 ^" wOn the Remote Java Application node make a right click and select New
9 p, g9 P" M2 W8 d
% N" e$ w4 f7 N7 F; Y w22)
* N; a8 [. r" U3 REnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS) ?% s4 k6 `- J# A5 y
8 y4 h# b2 ^# t/ @& }. I
23)0 _8 d# U) t3 C# i8 i
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
, c% _5 t( A4 O! K: n. X# t Q% z' ^( K6 m% v+ l4 s' O( m
24)# d/ B3 P: s4 G- d/ [. l/ V
Finally execute the JAR file or CLASS file in NX that you want to debug.2 Y% P$ e7 H; y4 q
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.
; q; ^+ G2 e2 I. a" O/ r& }6 l" F! [: W
6 A) u" x" M$ s6 ^& b( M" t- n4 ^That's it.
" P! [& l9 V, Y" `; g( v0 \ |
|