|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE 0 w8 M; I9 W1 h0 a; N1 T5 c
! ]8 _- v3 m3 a) T
(see PDF in the ZIP file for a pictorial description)
' F7 f$ m# @5 z2 L, t/ x: B4 r% u' n
Installation of Java and Eclipse
# `# k, e& b! ?" b& _1 t0 ^/ Q
5 ]/ l: g+ a/ E5 _1)
9 k8 A% ]# B6 {3 CDownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
6 f; a, b& a! [# s5 l3 \& w, @http://www.oracle.com/technetwor ... ownloads/index.html
! s1 k& e( h$ K6 S6 ^0 a" b2 m
7 {1 [7 g. b: ~8 h" u2)
5 g4 ~2 C, v ]/ {3 SDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads
- M9 U; r" P( e* hand extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”% l4 E# H6 Z4 Y- m
9 O7 O y" ^( Q8 _
* F/ h, d* N0 k! u5 tCreate a project with Eclipse
% O F+ O8 \$ @0 O* x4 X5 D5 n+ i' i0 M5 T7 x9 ?+ V6 a$ P3 N. c
3)
0 j3 a5 |% M3 N0 p3 w' UStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
Z& }+ B. t" y8 A6 B
8 D+ ^; S; M8 |4)0 i" z. c( B a1 n' y3 Q
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
$ {8 `& M4 ]5 h2 S6 B9 @8 o: R
" E* Q2 W! x# ~6 C. ^) r5 u5)4 n3 M# r7 [/ l ]
Create a new Java Project by File -> New -> Java Project
3 m" i" @# T) t. t7 d( G( F# O' W+ o
3 {/ V! @, n% R: w5 C6)2 y6 K; x5 Q; `
Enter a project name and continue with Next! n& `1 ]1 J# ?; R# l6 b
* v* n; @% t0 k- o2 f/ E" z+ J5 {3 F! A8 f
7)
1 L- B6 L- |0 y% nOn the Libraries Tab add the external NXOpen Jar packages and Finish# Q+ j! O6 I) S# `2 v9 F
' z6 g# n6 `& q( v6 u3 J8)
: P3 _* l. W, `- N8 @In the Package Explorer window make a right click on the project name and create a new Package (Namespace)
! y# m5 ]2 x8 b" C$ N, K3 Q6 l
, c! @; _( C) _, @. I$ }9)
: A* b3 ]2 b# q8 Z; WEnter a package name and Finish
3 l. z; Z+ A- ?% m% s* C H
5 I) a& n& O5 A10)7 Y+ ], u: a2 e+ L/ R
In the Package Explorer window make a right click on the Package name and create a new Class # ?5 R5 F! Z( r
6 O4 a5 v3 P, D( E- w6 ~# _
11)+ K1 G5 J& [! a b, ]7 N
Enter a Class name and uncheck all method stubs options7 c6 L: E/ d& n$ [" g
: b1 d4 i! D G' i) T! f12)
9 j2 W9 ]3 y8 n4 f4 J% u: H, b. ~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.) y- z. W2 o% j6 c: W/ o
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java6 J% Q% ?) D0 J1 M, A
, ^0 v+ C* p; p0 z( h$ ^: L
13)
2 Q+ d+ U( Q) I( P! x/ lStart Recording by Tools -> Journal -> Record8 O$ o, u3 _* |. u
( X8 \8 G1 G9 H) {: k2 K2 [" y ]' h14)
% X$ l7 J3 G. x; RCreate a Block and finish the journal by Tools -> Journal -> Stop Recording7 F6 ] V! }; x6 C8 W/ S. `* ~
6 I v3 V# `7 v15)9 c% E9 O/ b h/ c; C! i# f
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
9 D4 { E5 p( C/ o+ X# M
5 H% v" t; q) E16)
6 N# h- g v6 y0 m& G; tMake a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
8 ]/ R( z6 D4 c, y0 S. v: d, B/ p/ z8 q
17)
+ L' b* P2 ]. W9 W+ S KFinally we create the Jar file which is mandatory in case our package contains more than one class." x L8 }0 L- Z" i
In the Package Explorer right click on the project name and select Export -> JAR file -> Next
( w& k$ a, q" C
]3 b8 F* p% h4 k! I( v( l+ V) e/ K18)) k. \; G6 _3 a- c3 n
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable., t+ ~' q% q3 _+ D! p% ^2 Q0 D* a
4 ^9 _# {$ |3 r k19)/ @- {4 @0 O( \+ w/ c2 U- ?7 F& v
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish: D! @0 ~ O5 C
9 u! J( |6 E, ?0 N( s3 [3 d( Q4 m
6 X5 M4 C# a* I- xDebug the JAR or CLASS file with NX and Eclipse
+ x, c( @5 F9 }7 N, ~" u& }+ P
- q3 g# Y! u# A9 g/ z20). Q6 L& J0 y7 S5 w, F* Q3 y! ~
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 .
( ~+ c# v* E W& J+ B J7 O1 EDue 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.1 u+ y/ V3 ?$ w) J4 u: a
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.; G1 T2 n- ^4 R2 {0 ?0 L# \ C
From a NX8 command prompt, we enter the following commands:, Z& i" F' o+ C; F3 S @! ^
, T' ]$ E( r% } ]/ K9 _; B# n
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n) T, L1 `( a, a, }# ?% e4 f
>ugraf.exe5 d- q2 O0 g& k, m# R2 j8 O' H( y' w* q2 l
6 T, O% ?( ]3 K& m: [
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.( ]5 m8 k: h1 k8 ]; Z/ A6 @1 Z
Any simple class will do the job, for example a famous HelloWorld class.
- n2 @5 g; t9 I( U) C) D( ^: f! Z, X
21)- H( a& ~9 K( T4 T( L
Create the external access to the JVM session in Eclipse by Run -> Debug Configuration.
2 v6 h! v' T, v5 [8 XOn the Remote Java Application node make a right click and select New
; o! h s- @% i# X7 G' W" b* d4 Q
/ h8 k1 p* m Z: r2 W2 W. I22)
; N% _' r' H' k& j6 a8 ]Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS5 l# i( c4 d: `1 I: V6 Z( g5 ^7 ]& l n
+ |& j4 S/ n5 j. v
23)
6 i6 a1 V* U- T; @5 m0 j+ RDon’t forget to set one or more breakpoints in your code where you want to interrupt execution H( [& Q8 o% U
0 K$ L6 @1 G7 S( O5 n
24)
, t6 p5 [3 N5 I4 P+ B$ O1 ?Finally execute the JAR file or CLASS file in NX that you want to debug.
5 C6 @! p# [) z3 W. S" t* SOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.
) |% S0 k$ W( x# i7 m
$ K0 `! i# N7 D9 l, @That's it.* A/ ~3 o6 ]6 V
|
|