|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE Y& M+ }% T1 v; F0 \: {- u
1 z5 ?0 N9 |% E(see PDF in the ZIP file for a pictorial description)5 o2 i, L. r, I" S1 P2 G
$ v/ X0 D. F6 X) n
Installation of Java and Eclipse5 X- A* I6 z o% k# i, M
' ^& r W. i3 h9 d2 |* O! r1)
6 Z7 N/ r& i' n! ODownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
- \# q3 L/ J1 W$ jhttp://www.oracle.com/technetwor ... ownloads/index.html
5 }5 Y0 x+ A; U/ i5 @, x$ B. F7 ~6 D1 A% |4 |1 K6 p2 f [! j
2)
o2 x& F+ }$ O7 B, }3 p- VDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads 9 U% u; `" K" L( z8 J9 d
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”
2 M7 j6 \4 E# s
- i' `6 ?' C5 L3 W( e8 L# T5 v8 S+ i3 r) q3 l% @; t P' Q
Create a project with Eclipse 2 T9 j% L- ?. B* P8 R
/ t# b$ j& ` E8 _6 a
3)0 O5 R {6 W4 J) w
Start the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
: A+ p. A( I- u+ Q
' [' {1 z: Y$ M7 Q% z* x& D4)
5 U, }. C8 F FYou will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio
& u' z i, k% w3 P- Q! x
4 q( B3 `( A" e. W8 F- f7 e5 K0 y5)
; L9 P( x ]! H: CCreate a new Java Project by File -> New -> Java Project4 \# A& ^7 E6 z) o) x
: c! t2 L2 i, z% F) H6)
, }. U) E! K% Q+ wEnter a project name and continue with Next, K3 }' ]& c3 z' o
( r6 J& `( X* v5 x. y# p$ J4 p
7)
8 } F0 e w O8 i; BOn the Libraries Tab add the external NXOpen Jar packages and Finish0 I( l/ u. V9 ?9 C( g
( l* C0 I7 J' e H/ Z- Z8)7 J4 a% }; \: O1 q
In the Package Explorer window make a right click on the project name and create a new Package (Namespace) 1 C" W' S( }3 H
( ]- e; U% ?' @) [) L3 j
9) 4 D* s9 g' B, ~4 ^
Enter a package name and Finish% @3 E' n6 z; V
8 t; e) A4 l5 ~5 p1 k7 ]; x9 f10)
: h8 L- L; ]+ _ W) {In the Package Explorer window make a right click on the Package name and create a new Class
+ G* L7 g0 L. t" S
% U' O9 \* i0 P9 k11)5 Z) g3 F1 [! ^" ^6 @
Enter a Class name and uncheck all method stubs options# s# v" d& S7 ]9 n5 h6 x, X- K/ W" ?
) L- [1 f& V" B12)
/ b$ F" E) }" Z7 J1 D, A4 C& q! JNow 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.9 b0 v! Y. S$ w& ~3 i/ c5 e- G* `1 E
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java0 Q5 N+ V1 T2 Z' x
/ I' A+ J7 }8 e) I13)$ j0 Z$ q% n }/ `' U3 M; {
Start Recording by Tools -> Journal -> Record
+ x( r6 Q) E6 l. l7 A2 R% i2 b4 b0 ]. j% H
14) ! ^/ J6 t- E) J8 d
Create a Block and finish the journal by Tools -> Journal -> Stop Recording- a9 U1 {" B8 S9 k
7 B: M. n9 j- m4 F' B3 i15)! P( r- q% Q1 R7 Q! E
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file x- z+ y8 w0 F* s Q/ ]
- i( u+ U# T! x& c0 X16)
& N' g; S) A! i; K7 zMake a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
4 w+ W- I" q) A! \0 f, s) R8 I0 }" }6 | a! g
17)+ g3 ^. Z' V" f& i0 ^0 P
Finally we create the Jar file which is mandatory in case our package contains more than one class.
! H" D2 T) P8 O7 Y! y5 Q5 KIn the Package Explorer right click on the project name and select Export -> JAR file -> Next8 }: D7 A+ l2 C9 z6 J! d3 P
. P9 N0 |: z; c18)% |* R6 n* A1 q8 K8 X6 A/ m
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
0 \0 Q. f, v7 \! B6 Z8 |2 `5 ]. ^& ]: R- R; j3 Q7 e
19)
! u, E( h5 h4 g, m3 W5 RThen proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
9 J" q0 e9 L2 r# ^/ N/ j
/ j1 j0 p* e1 m0 l7 G% U3 f
, T" S- w8 O1 h* q( s! i; A# u% S" hDebug the JAR or CLASS file with NX and Eclipse, J4 G; ?& `5 V' {/ L8 _
, I* A6 a9 A) _) A20)) D r! S4 d4 n$ B3 c
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 .! Q. L6 s, M2 l/ z: i$ o g
Due 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.; R, H" `. U9 ]. [
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.5 b( p( |! [8 v' z+ v/ o: Z
From a NX8 command prompt, we enter the following commands:% T9 B8 h$ v5 E
3 X3 X9 N4 s, O. u
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n/ ?6 O6 u8 k4 {- S
>ugraf.exe/ W5 Z4 H2 `# q
. ?7 a9 S3 u8 Z9 T5 s
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
9 o- n' S! H) Y3 ~1 T, lAny simple class will do the job, for example a famous HelloWorld class.
2 m$ a, H9 F+ M) {
% R4 `" C: r3 C; B7 W- y% w* M( h21)
2 j1 f8 i, p& u9 d- CCreate the external access to the JVM session in Eclipse by Run -> Debug Configuration.' p1 d" [ ]3 I4 X, {! P; c
On the Remote Java Application node make a right click and select New . k: [+ u" c5 {. s
Y* \ v2 ~; H, m
22)
( \" _6 `$ p9 ?: g- iEnter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
+ I2 _9 b: d0 e$ \8 d" \# V, Y7 b/ _) A5 l
23)- W# I% C2 `* q7 Z! o9 X
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution6 U. ~3 I7 c, D! b$ E7 W
) B. y; }1 N+ C' F9 |2 i24)& l4 W0 C: _( Y! u/ g8 u
Finally execute the JAR file or CLASS file in NX that you want to debug.
! P4 ], o+ f& w7 T0 _' I+ ?' DOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.' R2 Q* q9 K. t: r4 o/ ^) g" l
3 a3 k8 D. f d2 B' ]& S& ~That's it.) y2 p4 z- L6 }# @
|
|