|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE
' `9 Z: l! p s' i1 [4 ]/ j# E; s% T4 {6 i$ ]# I8 s) v
(see PDF in the ZIP file for a pictorial description)2 w/ R/ C7 C. N% V- K0 p+ d _6 m
; O6 A" D0 e" I
Installation of Java and Eclipse! B; p" P3 `# d O0 W6 y8 a) t
. b6 T5 P6 |& u9 I6 N! E. q& G
1)
! D2 P$ M% v& MDownload and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
_" ^, B. q* |" }0 i# r6 Q6 phttp://www.oracle.com/technetwor ... ownloads/index.html - U9 s8 U: k1 r& G: w5 p! v3 M5 W
5 o8 f" r l7 P. a5 e3 L" J; _2)
5 A6 p% Q+ _0 M! i @ fDownload the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads
~. l' k# V+ {+ qand extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse”3 w/ v2 j% U7 o3 j
% C! Z+ ~# R% ~! h5 [
/ r% |4 o, \3 W7 v2 SCreate a project with Eclipse ; O+ [: Z' s7 Z/ c. A
$ y6 C4 o8 t: v# Q; e+ T
3)
" K( o. \* `: @; [1 rStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
* _' a6 f) e2 P1 b3 [
4 ~/ R$ E6 f4 W* D1 T) p7 j4)! R, }$ D! ?+ R1 A- e/ ^) ?2 a
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio4 H% U8 Q) v1 L! v- e9 \2 u) Z# P3 S
' H) }/ I: c+ G9 u- R/ ]
5)
9 L( O# @6 N/ J! Q3 |Create a new Java Project by File -> New -> Java Project
: @9 H3 [: i+ x4 `) |7 ~3 ~- E2 M y/ l9 Y' p9 z7 |+ V1 N, @
6)
% L3 Z5 v0 d/ i+ A" U; i$ JEnter a project name and continue with Next
1 N9 O2 ^/ R# T4 w4 U1 B- c% Z5 Y6 g( E( {4 u* @( d
7)
- ?1 N; y7 h+ h# B4 h! QOn the Libraries Tab add the external NXOpen Jar packages and Finish
4 K8 g- H* n# j+ C, Q: x `. j$ m! o; V4 l$ Q' T
8)& `4 ]8 ~+ e! |# j+ V' }- G
In the Package Explorer window make a right click on the project name and create a new Package (Namespace) 2 u2 k$ r* w# @- X; ~2 U' X
1 W# \5 q% @& C; U) B4 a( ^4 y
9)
* `( C8 e$ c) @0 [ C6 S) KEnter a package name and Finish
0 Y# A( d# h# E7 W. b/ P+ H# D( ~" ~) R* _! G
10)
+ u0 x6 [3 E) k& f* iIn the Package Explorer window make a right click on the Package name and create a new Class
% B1 Z M6 k) R! S g! H" {, p/ |! A/ C+ g" e6 a& l% C3 L
11)
- W0 x% O7 X9 k, DEnter a Class name and uncheck all method stubs options0 w! s( E9 o! r* X/ t r
1 v1 J: }. _6 D: G! U/ c; K12)
9 A: S, l9 D z! P9 qNow 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.
" e+ E3 ?0 s! e2 a& tFirst we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java8 M. H3 ]$ b* ~+ z: W0 T
" u, J( e% N" A1 R
13)
+ E/ o5 H/ ]$ Z% Y$ b) f* uStart Recording by Tools -> Journal -> Record2 Z Y; V X% J
- ^, b* `: ~3 d6 W$ t: @
14)
; o- j; b& W$ BCreate a Block and finish the journal by Tools -> Journal -> Stop Recording
+ D# Z% U4 Q$ j' T% ]& a4 `4 [# r7 I
15)
4 A- G3 y; ?4 t9 bOpen the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file" k( @ S% f% x9 R$ D/ P
3 d+ z+ z m/ B5 z, z16)0 t, @$ l5 h2 s% {3 N6 {
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”
& O Z5 b* F- G6 y( B
% U U8 X% w% C. @) s# b17)& ^6 S8 [7 X2 {. o2 ~; v4 x# t
Finally we create the Jar file which is mandatory in case our package contains more than one class.
7 O- X. ]8 _3 @7 G3 S: N1 JIn the Package Explorer right click on the project name and select Export -> JAR file -> Next
! k& n3 j$ m5 L; @3 U5 n j
, m* v t# F4 D z8 ]18)
+ A; r# }& |! L n) C3 aSelect the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.2 d4 y0 ^$ R w9 ?# C1 T
. @: ^+ u4 k& r) ]9 q- a
19)1 M1 ` K _- D$ C8 {: w
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish1 c# g4 m3 s! W: j& l& @' h, B
* P" B6 H% P1 R- |) m |
% y" E$ F+ Q4 U; |7 S: R6 ]Debug the JAR or CLASS file with NX and Eclipse
B y M& d# S2 {
7 {5 W3 ~6 c1 M20): U6 H' s$ Z& `4 ?! B
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 .' }( M k( s7 w+ s
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.! O# |, W; n4 l. }
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.
+ R t% N0 X/ z+ V: o4 ^) D1 LFrom a NX8 command prompt, we enter the following commands:# X! s! }0 \8 o! V& X- q
. Y; g3 f. O0 H9 v0 E0 s>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n
( C8 E1 u! Q! D: [>ugraf.exe
# Z+ V) D* O% s+ h& ^5 G0 r5 ^% U) }* r9 B
Then we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
9 b$ {* \# O- PAny simple class will do the job, for example a famous HelloWorld class.& G, _. y/ P$ |' i# I1 ^. ^
+ q0 m/ _6 n8 E" v( _: n
21)
: @: D2 _3 @4 F* ACreate the external access to the JVM session in Eclipse by Run -> Debug Configuration.
. I: ~1 c, t% T, F) ZOn the Remote Java Application node make a right click and select New
! W3 x/ f ?9 A2 o/ _! |! k8 ]# b5 E' V/ [1 Z
22)8 n8 A g, T# Q8 `" M- D1 l9 O
Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
$ L/ B4 {0 z l9 d3 g3 Z# X
& |! O1 k5 g8 W \, q8 ?* a23)
8 v! d. g: {. m" b! R0 n b1 D8 M+ ADon’t forget to set one or more breakpoints in your code where you want to interrupt execution, Y0 [1 r7 W k; x% R4 t6 [) v
+ D( _$ Y- T" U- I; [; l24)
8 Y% b# Y; _) C2 P0 F3 Y" ^6 QFinally execute the JAR file or CLASS file in NX that you want to debug.
! h9 r+ K# B/ K# _1 K3 u! C5 y8 YOnce the breakpoint is hit, switch to the Eclipse application, confirm to change to the Debug Perspective View and Step through your code as desired.6 q7 u$ Z/ Q, Y+ J6 i
9 b# H' u- B7 c2 ]
That's it.
6 ^! ~9 w5 J/ g! m, u5 Y0 ^7 B |
|