|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE 2 U, b( h' v4 y% L* G: i- L
: N8 \: L9 f. [6 e
(see PDF in the ZIP file for a pictorial description)
! i1 Q* ^! D" s/ M( C
; o5 p$ y: ]' j) g& S8 ~$ w( VInstallation of Java and Eclipse
+ x# s F% T1 E. _
+ v5 j6 S/ o4 ]/ R8 ^2 a& j9 Q0 y; N1)
0 A1 M4 R* _( }, G3 LDownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from8 n' T4 d0 Y- P9 g& n% e
http://www.oracle.com/technetwor ... ownloads/index.html , R5 A! q0 j2 @& @, a* Z
" Q; \+ I2 ]# E5 j% D+ U
2)
0 o3 ^2 E6 o: CDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads + g0 Q1 E. Q8 ^$ [- H; ^
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”3 z! L$ @* s, \: I1 q" e
6 ?6 X( a5 O/ k# N: M3 ]( X" I
3 M' w6 s' p6 E2 c0 V
Create a project with Eclipse r4 q; ~) j1 C( x2 E E
5 p& B9 G9 l% ~3)/ g0 Q t4 [# A& \9 w; z
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”& D& D' D4 z) y; U/ r
0 q( s; k/ t* g5 a
4)
: P+ j7 r8 P5 d2 J2 B7 S' K" sYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio6 N; @! U$ d+ a6 d- P
/ E/ t P) n( v6 v
5)
0 ]6 p+ D: t% G9 ?9 hCreate a new Java Project by File -> New -> Java Project$ v/ x X, J" z
2 v+ Y7 t/ z, n9 P6)# ?6 w% L- y: V: n I2 e G, N
Enter a project name and continue with Next) ~ \2 ]1 y5 G" m+ L# k* j
$ a( c) Q7 v4 i3 i# r: h3 U* f1 w
7) , r/ r7 @6 [/ C/ W
On the Libraries Tab add the external NXOpen Jar packages and Finish
5 P" _$ R- a! R8 Z2 Z! ^6 I U0 J
% Q* h' w. U5 p* e4 }* F$ X8)8 v; u( `9 f8 m3 ^4 e5 p
In the Package Explorer window make a right click on the project name and create a new Package (Namespace)
! a+ X8 S. F7 X5 y6 r. ?4 }' |7 h1 Q" D- L* s$ V
9)
$ T3 v W) l4 h( _( i- O5 sEnter a package name and Finish6 d0 L8 a1 |' f6 S6 s% h; b
+ B4 {6 V/ O* E7 A2 l& u10)
2 B/ k! \/ j6 q+ p, z8 \; eIn the Package Explorer window make a right click on the Package name and create a new Class
6 i% Z& j- J, ^8 v/ I* `8 j6 a% Z/ B, Y/ K' P
11)
0 j; h6 B; ?4 ?: b& P" _Enter a Class name and uncheck all method stubs options" I( N% ]. ^2 [9 \* K$ v A
3 S8 a4 k) N, w$ q12)
* B6 o C* N$ }* j% m' v) v. {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.
- ]5 Y9 S( z1 P9 R+ A2 Q$ S* H X: DFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java3 |5 D7 R, }' s$ V' }
' S) R/ K9 W6 J4 Y5 B2 r) L% g! n
13)
4 ^6 {. P ^# c0 `2 B {Start Recording by Tools -> Journal -> Record
6 f' q/ J5 x6 |" k* A& k0 O+ U' L# C' z6 D' t5 Z0 G
14) % p9 Y( N9 `) a: u w, [0 J
Create a Block and finish the journal by Tools -> Journal -> Stop Recording
! g8 y3 c+ O, X, G
* W3 w& _- _( K3 e* ^- p15)
4 N6 o/ I( C9 jOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file; Y* b& l$ K v
! d; _. N: N& A6 H- S% b16)
/ I6 _, x. g& o$ O( r0 WMake a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”; h- |2 N; C& M7 d) H0 b
# Y- K8 \6 r1 `$ a8 F17)% X$ m3 B0 B+ U6 g a9 e
Finally we create the Jar file which is mandatory in case our package contains more than one class.
- ?+ N& x5 `9 `7 [) A- Y. gIn the Package Explorer right click on the project name and select Export -> JAR file -> Next( L/ K* Q x4 m# }9 D
, m- V5 B: U. f. m6 G
18)
& n3 |2 V# E- A5 d! {- z$ nSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.! v! I" m6 o* R9 H
% |5 B" V5 y" l8 ^- j19)
/ I+ y' |* v) i( s* A0 \& x/ O2 LThen proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
8 e3 n/ S" v3 Q# {2 n% Q6 ]# @5 B3 p8 W2 P0 B3 r0 j8 K1 k8 B; U
2 `7 X, w8 F) M5 _
Debug the JAR or CLASS file with NX and Eclipse& U2 r+ H$ o5 u! U# h) O
5 P! o3 D, q% h& a; O/ M5 V20)
1 Q ?) L. M1 XIf 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 .
O5 ~4 l* C8 s: D( i7 GDue 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.
& l8 F0 V5 b1 }# M3 TIn 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., L+ x- y4 |: N
From a NX8 command prompt, we enter the following commands:
9 [# }! O6 [) y: b$ v: X' m/ E b3 x. o P% o X5 c i
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
0 n: F7 |" W6 v1 g9 ?>ugraf.exe4 n8 k, q' a/ |& t3 O. ? P
, t7 f: ~. M1 N l
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
8 Z% i, X1 |0 B: `# t/ nAny simple class will do the job, for example a famous HelloWorld class.& X/ P% {: V* A* q
, V: _/ v! Y! Z. @- o
21) n0 V- f( f2 E4 ]( Q: t- R( ]3 D
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.# {! M3 m# h! @! K+ Z
On the Remote Java Application node make a right click and select New
; ?: _! k( w/ F* O( x! j. E
4 ^- j2 P$ ^9 G* J# B22)
+ F( _. [7 @: y) q7 d! p9 oEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
0 n0 Q6 P, B" O4 u* }! B7 N1 X5 D; D$ R, Y
23)
) {8 [0 o1 j1 bDon’t forget to set one or more breakpoints in your code where you want to interrupt execution7 W: N% H& y4 S: s
7 I1 }7 {* U3 E0 r
24)
6 L t" i( F' d, S% m' x5 v1 W# c* b: M" IFinally execute the JAR file or CLASS file in NX that you want to debug.
J2 {1 W7 p) N0 wOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.3 t% o3 x9 g' S
* z7 C8 M9 o8 }5 m* J6 z: Q
That's it.* `% J6 S* U- s3 V
|
|