|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE
$ Z1 Q r5 d, i0 H* N6 N2 H6 }) c b, v
(see PDF in the ZIP file for a pictorial description)+ ~; l, ?! V4 g8 j1 S# O
( ~$ ^( i- Z- s; Q& `" I6 R
Installation of Java and Eclipse
+ n& I- N! ?% X" G" }2 [. B$ a# ^6 l) |( ^2 G( G/ o; _* n
1)5 K0 M* T, h5 x9 G3 A2 C
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
! B8 C. _) d0 M5 H; T5 Fhttp://www.oracle.com/technetwor ... ownloads/index.html
/ w, N9 C+ z4 ~, `, @* u, C9 x! y5 g' k/ z! y! D
2)
7 t- \1 n8 E2 W- Q( ^Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads $ E: k' O$ ^0 {4 F) q
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
! S& ~7 z& F7 r( J4 q% V5 t \' e4 ~9 e8 C& q
" }9 }( p5 l& w0 W# h( a, }/ }
Create a project with Eclipse
K r _( l4 P8 x1 L2 N
4 Y4 p/ F: p9 v+ n# v- \ k3); u2 m" l! i# u
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”5 f/ J7 }+ z6 l! X( {' G8 j: R" Y9 ~
& g8 M* s$ O6 d; d$ H6 s2 L4)
8 C6 k& _8 Y Q$ u2 jYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
. H& F% z# I. W" O: y
i* P6 a0 V1 i5 ~- i7 F5)$ s3 N9 x7 O# W" D( f) L
Create a new Java Project by File -> New -> Java Project
. C# g, M! ~9 G+ G, w0 t2 g
/ V* v3 k0 L7 C- u0 U6)' c6 ?& U. N% E1 N3 x2 W
Enter a project name and continue with Next- @* j$ }4 _4 k6 o( |5 S( w
7 m0 o. S6 O) c0 S7 t) N o# l6 v4 f
7)
3 C0 F8 t6 h# y. NOn the Libraries Tab add the external NXOpen Jar packages and Finish% M( G2 I& A2 d
- v7 P4 x* q0 @3 v4 G4 ?
8)
% I/ E+ V/ b+ v DIn the Package Explorer window make a right click on the project name and create a new Package (Namespace) * G" B' u/ d) c
{) x d& R* f# _* k+ ~
9)
( @8 W5 Y2 s6 R6 \. S) G. SEnter a package name and Finish* C8 y! ^1 k; d+ K# W
8 I+ @ X3 m' n5 u- p
10)
9 z% Y f% C- R3 @% aIn the Package Explorer window make a right click on the Package name and create a new Class 2 v" q" ]) [" n' D) ^# d" x0 }7 U m
5 o. l3 W3 e6 `1 d11)9 O! f1 W4 I! m l
Enter a Class name and uncheck all method stubs options
" F7 C: T, P" ]- |) a8 H1 w. E) t( q2 H& ]8 z
12)
, w7 ^% {" r# d; f. Y* bNow 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.; P" _ p; ^2 Z, e9 Y
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java8 j! t" ?/ V# g0 ]
0 b4 @" c6 E ~% _
13)) {4 j5 |% p' A$ r; Z
Start Recording by Tools -> Journal -> Record3 v1 W* i5 k( l5 a; z2 a% b3 \' Q
1 d0 B) x6 P% x. U
14) 6 q+ E) V1 R: U) A3 n# N
Create a Block and finish the journal by Tools -> Journal -> Stop Recording3 @4 _( d6 c. V: V9 m
2 K7 h0 \" ]' F0 ]15)% U, A$ w* p8 U0 S" f$ Q
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
: Z0 A4 B# E6 u: n' U3 ^- y# V& k3 m8 H8 y; K9 ]
16)" l v, z2 z' I4 D K; J3 A
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”3 D# F: @3 h/ ?
6 U/ k& ?% B' ^/ u& r( S/ e s
17)- K9 p2 s! M3 x/ \& z
Finally we create the Jar file which is mandatory in case our package contains more than one class.
5 F1 {3 ^5 \: X5 n& jIn the Package Explorer right click on the project name and select Export -> JAR file -> Next
' [& M9 n p6 T& i4 o4 ^$ W) S. K- x) X9 j+ n. s( A
18)5 R$ p% S+ y) z. Z0 g4 ~3 Z
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.3 O) {8 D) g# e( o$ c
* R# Z2 G" A6 {19)# j1 D+ }/ F) ^0 B" {
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
4 q* E( `, U. ^7 u" j
' s& {. N& A; l; W" a! }( E7 v( p; W4 {) J5 t( t% M, \
Debug the JAR or CLASS file with NX and Eclipse
+ `6 l2 u1 P! J/ }2 O; z- Z, f6 ^5 `. j
20)$ T7 ` I9 e5 P5 f. D
If 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 .
) F- V/ C- L( b: s- t1 x* T7 mDue 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.
# Z* ^$ H+ x! r: QIn 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.: v; f& d: j$ [; P' n% ~
From a NX8 command prompt, we enter the following commands:
J. U% k+ n* ~6 T8 z6 W) l. V
: M* ^5 o3 J( v% L>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n2 O3 l; B8 m- \( n# d' _/ F
>ugraf.exe% x. x: ~6 J* H; Z8 X
6 h! ?5 Q2 r+ qThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.$ x$ \, B7 ?! \8 P3 p {; M
Any simple class will do the job, for example a famous HelloWorld class.
6 W; v2 j, N: F+ O+ h7 X5 C M2 c
21)# Z3 W6 d; L- r9 K
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration., V) l3 G6 U& s* R5 F. H) A9 n
On the Remote Java Application node make a right click and select New
7 d1 g7 F% i0 K7 b, W9 e2 O5 v# p5 |) W U
22)
, ?# k: R' u, A5 W$ S" L6 t2 bEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
" m0 s3 H0 e: `7 s1 ^+ X/ J( S7 k0 x+ j4 \2 g% g4 M: f9 S
23)) M% I. E8 g% B3 a
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
5 D. a- ?, b( m% z4 J- T" q" }
! n# i6 z3 [6 a! h24)
7 y9 {# o3 n" F5 G8 Y5 UFinally execute the JAR file or CLASS file in NX that you want to debug.
* }; t0 O! H9 y- ?, eOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.2 @* F; [6 p" ]. y
5 S8 [; `7 F, r) g" rThat's it.1 M* t& q) W, R# f6 ^9 ]
|
|