|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE 4 D% ^0 q, t* j; }- Z+ x" R
; G! ?, A3 D5 x% O9 P3 I9 k9 [(see PDF in the ZIP file for a pictorial description)6 N8 G" G" [+ v! E4 R, _
1 t, _( `0 M' W3 U: }* J
Installation of Java and Eclipse
+ B4 j8 d2 O! p& E% r" O3 U/ g; X! n1 G2 u. W
1)! H$ z6 p' \6 b+ a6 T9 `, p) J/ I: A
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from$ I; F1 e' \: \- H) b2 g/ s
http://www.oracle.com/technetwor ... ownloads/index.html
* i S6 X1 `2 F# E: v# Q1 J. Z2 m$ ?2 G$ c- ?9 g, a' K" ^
2)
6 x8 W$ H; T7 E; A0 ?Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads - Z6 N% H7 F3 e. t
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
$ Q& }) F* v: |* Z) Q3 Q( v/ z$ g4 |9 p0 N6 A
. c' i- R1 ~' T7 Z$ Y) s4 t3 u
Create a project with Eclipse 4 q* w; p, i0 n7 \; `$ X. o
9 v+ F3 W5 P) X6 C" a6 @
3)
: Y4 H, Q5 h7 w" O# x7 @Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”& z' C& ]4 j6 J) q+ u" Z
3 d. @: D. ]# x9 L o2 g# i7 o( e
4)1 Z1 q7 M/ `0 F3 O7 {& p, [1 J
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio. t* G+ v% \8 ^4 @0 {
, y( V J# s+ J4 ]/ J" `: G5)
0 ~. M6 ~4 F7 y B2 \Create a new Java Project by File -> New -> Java Project/ X( I& _( G5 D& k {- E H
( ^8 F& a* W, A& z) Q6 O9 x7 B- i
6)
2 D4 ]/ s1 M z) j$ `! p. HEnter a project name and continue with Next1 L$ n; w8 A0 ` \1 o; w
% g$ M% S4 T6 t7 b9 @3 e7) ( L9 {& |1 q; m/ p" ~# T
On the Libraries Tab add the external NXOpen Jar packages and Finish9 K( q G. E& h: j! `+ u
# R9 M0 Z/ ]" y2 s0 u' l& d
8)' J+ e v# n a/ K2 ?" e6 z! E
In the Package Explorer window make a right click on the project name and create a new Package (Namespace) & m, S5 d" \! i- C# d. S" U
$ t6 h y) K1 ]- o9) & B; w1 ^9 k( a' J
Enter a package name and Finish1 A: a3 o/ d. z" \8 z7 M
+ _8 D$ J+ {( @9 K
10)
4 a" w/ Z, S4 \5 EIn the Package Explorer window make a right click on the Package name and create a new Class
2 e$ G3 R. [" D: B1 y* S S
7 c) L' i5 v8 ]3 L11)7 U# u- x- k5 F4 }7 M
Enter a Class name and uncheck all method stubs options
+ t& B9 b8 P5 R, _4 f% i* ~3 S
1 c* V9 l+ ?! \8 H; K2 ~12): Q( t3 z9 c; ]+ C& 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.' V* c. M' k- e$ N
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java; [, X! r! W8 b w: m% t" j
8 q5 M+ c5 a* X8 Z8 ^
13)
, F9 Z7 z1 _; G% T; l0 ?: g0 hStart Recording by Tools -> Journal -> Record
! w! `4 A* b1 ^
5 l1 Y! D3 V+ [7 e7 s9 @, D14) 1 R* B) l. l' C8 b5 M
Create a Block and finish the journal by Tools -> Journal -> Stop Recording a$ `6 P7 H4 m2 N4 R) v% N
0 q; ~, `+ S0 F15)
( C1 H. D+ }! B6 l$ TOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
7 J8 }" T. E* I, v
: h; o. F/ I, P1 `16)0 D; B0 H3 I7 r4 V' I0 v9 p
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
8 e& [6 X" |+ b/ w3 Z. p# \5 D; |. t
9 B" L$ `3 w) f. Z& B17), O: J1 @; ~+ d7 k7 h; W( R
Finally we create the Jar file which is mandatory in case our package contains more than one class.
1 f- K1 t% b3 ~7 j _. LIn the Package Explorer right click on the project name and select Export -> JAR file -> Next# ]& j" K2 G5 P$ i2 S
' u2 h. R2 ?* u: W9 e2 B2 D
18)
v/ u2 h6 }% j3 k7 n q* BSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
4 ~& P( r7 g; B7 p# S. Y' O; T# w) r/ h
19)
8 {( w$ ~6 ~; S6 R8 T5 q% jThen proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
0 ~, R8 O; ]% W1 |% p4 l. {* j# m. [+ Z0 C
' p! u1 ?( K3 C# ADebug the JAR or CLASS file with NX and Eclipse
* |2 u( G/ H1 _! C1 s8 S+ ~' f- h3 k0 O- \3 g! J$ D4 ~* ^- e
20)
/ v3 B8 G. X5 F" Q% n F$ uIf 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 .
2 x# f$ B: v- W7 X5 M4 VDue 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 Y0 y5 |6 p( u& f5 a KIn 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.% I) L2 G. c% P. v! x
From a NX8 command prompt, we enter the following commands:; }0 C; z' y8 X" D: w7 n7 X, Z. y' g
8 h7 n/ X8 y z! [ t8 S" q
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n7 p1 W3 v P5 P) K5 \
>ugraf.exe
- Z% q5 E) \1 L) W9 q6 r) S9 a5 e- g2 `; ]! B- R! @* s: z' c
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.! z% N: Y. x: w1 T i1 h& X
Any simple class will do the job, for example a famous HelloWorld class.
" f. S3 v3 @$ a2 g2 A7 n" u( a2 n9 Y
21)5 f( W+ H2 ]+ w+ n, w7 ?' K
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration. R% u6 e9 s: u) x u# k
On the Remote Java Application node make a right click and select New
. M4 J1 |! }4 d& S0 q8 z5 S- q7 k; q2 z+ m1 v) X) W: B2 g
22)
7 o, K$ T) ]: v! W _; X6 Q$ rEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS. S, P: q3 D* h `/ e: m( S0 T
! v- T/ S+ e. K9 t' L4 i
23)
1 V3 r$ o$ b% M; { kDon’t forget to set one or more breakpoints in your code where you want to interrupt execution9 M/ E( R7 t1 z' S( _8 Q# u
% z, N2 l1 _. k5 ]: ^
24)6 f N: D V$ j. e a
Finally execute the JAR file or CLASS file in NX that you want to debug.
: |) T, A/ ?5 q8 R" h" o+ j9 E5 s/ y3 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.
Z! g* |+ h' C% d6 `1 H4 j3 D6 O6 r' r* d% {$ g# j1 ?
That's it.+ V2 R3 W) r0 Q) S4 P
|
|