|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE
- M+ }8 f$ V% K! Q
9 J0 V* x3 Y1 z ^(see PDF in the ZIP file for a pictorial description)
' e& B/ j4 [3 U6 c( I. b5 z% U2 q3 m( M/ J, n
Installation of Java and Eclipse
3 B3 {( k& q# ]5 C! y% {% {8 ?8 u3 o& Z- h7 n/ k8 K3 T9 `2 {' L% L
1)6 P4 w! l0 R( }- ^6 P
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
7 Q+ Z* s. E8 w0 dhttp://www.oracle.com/technetwor ... ownloads/index.html : E1 v4 a6 @" R( f9 E: E! z! [
3 A) e% P. a$ ~9 S2 r5 S2)% V% a) r% Q/ R w/ o
Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads * R+ ~0 g& E5 `- P1 N
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”2 J, q+ `1 B2 ]/ _2 p5 ^
% C9 O8 }5 R+ D
: N h: Y" e" N/ X$ y8 P( `0 g: X8 ?Create a project with Eclipse ) ~) w( w$ ?% {4 y5 L
8 F2 W& t: n# r$ D( J% y. V0 U3)
( C: @5 d9 C8 c9 nStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
: S. ~7 J& S- A" v$ W0 j% l
: O$ T; G! |6 V# Q) s$ h4)
7 J3 c9 R6 z7 k7 Q5 dYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
# ]9 b3 k$ N! ?3 d& g7 T7 P2 ?5 g! T; S0 m$ `5 _, s5 N
5)
3 R! ]3 ~, H, |4 cCreate a new Java Project by File -> New -> Java Project" K- r9 {2 @" o8 y4 ~% B. B" s9 H
7 v& Y z- S6 n3 J) g% i3 S% S% |8 S6)
. p* U8 F `+ Z# f5 P, d7 A! {Enter a project name and continue with Next3 N2 m+ o8 E7 ?0 k# [
' G- \7 T1 L! B( I1 y" T
7)
" j8 c1 |- ]* q) _On the Libraries Tab add the external NXOpen Jar packages and Finish, u, P0 Y5 U/ \9 R
1 G2 m' Y' D' o6 S) t: \# S
8)5 a: O; ^3 c, q* z- _
In the Package Explorer window make a right click on the project name and create a new Package (Namespace) 7 D( R- N( M* i, j0 l
2 \ o1 ~1 P( Z) e9)
* m' A$ i. @7 ?1 n. G0 V- pEnter a package name and Finish
$ W% J6 D" Q. Y% t
0 Y6 \4 u- c, L* j* t& m10)/ g& t* y1 P$ p1 y- v' O
In the Package Explorer window make a right click on the Package name and create a new Class
6 T) W& {/ O& C4 W4 w1 O3 ^# M
1 q& U0 N9 b/ W+ {+ `11)! C2 i/ A- ]; `( m# w+ X
Enter a Class name and uncheck all method stubs options) K. f/ q" }7 k5 `" q
3 {2 P; @# z$ w3 ^! K3 D
12)8 ]; k5 u7 o6 s( F. c: v6 f" u3 ~
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.
1 {- z/ L! x- o+ B9 V3 \8 m+ gFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java. F, Q5 m1 h& V/ g2 @5 _; y- x9 Z
5 j+ c, N! f' t5 d13)
& C1 S1 D* f; @; }' q' rStart Recording by Tools -> Journal -> Record
n! I! l" ]) _7 y
. ?! N- b2 m4 I6 f14)
/ ` [ S ~. Y4 Y3 _( cCreate a Block and finish the journal by Tools -> Journal -> Stop Recording( d# Z) I$ g+ I$ i
. n0 Q2 l$ ^4 j6 k( i( @$ A# W# Z3 N
15)6 A" j- b) X. T6 M' U! D" |& T
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
# A) j" m" l$ W# q+ R# k- l9 K1 F" a, i U
16)1 x" @( z) g0 S T! q5 E+ O
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”. d* ^+ ^6 w8 n$ g& z
h" p/ L- N# F2 R X9 A3 `
17)' j6 w% n& ~1 E7 V- R+ s$ G
Finally we create the Jar file which is mandatory in case our package contains more than one class.
0 \8 k/ \' I+ bIn the Package Explorer right click on the project name and select Export -> JAR file -> Next
" M) w0 K) G9 [: [
' H0 x7 h$ P8 l, C" o18)1 W% t+ A& }) y: t2 H% |2 {, F1 K
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
* X( m9 D- X+ d* I6 w6 o7 O. g4 z! v
19)
9 W# f; W+ | x" [Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish! R- @2 k$ i) l( I$ Y% Y' ]& v: z
) h2 x, }2 j5 s. E4 j
. m+ ^8 Y y, v; w" YDebug the JAR or CLASS file with NX and Eclipse
+ I4 p( B g8 n0 P
- B7 q" p- g5 m& ?5 a1 V# _20)
% S# y, d) f4 ]1 w4 P7 K. yIf 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 .
/ t) w! M; c1 @! l3 V6 x# ?* ODue 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.
8 Q1 G, G0 K4 [, S* b& z4 FIn 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.: }2 c4 e/ E* W
From a NX8 command prompt, we enter the following commands:9 V9 v) |( P! ?( K
G$ ^# x" n$ \) @! d- s" H( `" l
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n# X9 `; p* R" Z2 z
>ugraf.exe
9 z0 R% q# y0 P$ t
7 a- C0 K& \) m1 |; DThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file." X$ }2 w$ c' d! p" C' J
Any simple class will do the job, for example a famous HelloWorld class.) C* ^5 [9 S3 S* L, K
' b6 ?0 F N6 `( r" i/ I2 Z
21)
: G* }; _ M& G4 M+ YCreate the external access to the JVM session in Eclipse by Run -> Debug Configuration.
5 v4 J% t% j& h" Y6 O vOn the Remote Java Application node make a right click and select New
$ ? L7 p( W; _- o# E& L) ~! Z$ Y# H1 A5 v4 V6 T5 ]" [
22)& F9 c% [ c8 J; l' R
Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
" [6 @- i' E: Z: Y1 k0 e, H2 e: N3 c5 H
23)/ G: s1 T3 z9 [: K4 g& b
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution* h' b6 [7 `; Y" a4 w
" E/ J1 P; Z1 M
24)2 B# D1 g; f W2 S7 E0 Z3 i
Finally execute the JAR file or CLASS file in NX that you want to debug.- _- J4 v3 Q( Y L, x# k
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.% h1 D% S+ Y# ?1 v4 B' ]; v
- P+ t P# c0 P6 F1 h
That's it.8 R7 e- I0 z! j6 A
|
|