|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
DebUGging NXOpen Java with NX8 and Eclipse IDE
+ S2 F' g; \! X* r, y: |. j
, i+ i. S' o+ |& m: q! b+ c- `(see PDF in the ZIP file for a pictorial description)( \! W2 D5 \* j6 ^/ q( }; U0 J
" i9 @! A6 s o: G" a" T5 y+ n; S
Installation of Java and Eclipse4 R" v. H2 N3 S) N! G! m
. c* T- Z7 K) a& `5 c' K2 R7 B1)5 E/ Z }* m) p y" ^2 H0 \
Download and install the Java Standard Edition Developer Kit Java SE 6 (1.6.0_14 or higher) from
( e6 V0 f+ g" n+ g* B; v. O4 V0 thttp://www.oracle.com/technetwor ... ownloads/index.html
! P. d& x- B# c% ^2 U2 s2 F, W+ c' T
2)6 M- }" T. r1 [, H) T% ]
Download the Eclipse IDE for Java Developers from http://www.eclipse.org/downloads ( |- ]) K- d' X4 r- W* Z* L
and extract the ZIP and its ‘eclipse’ directory content to your preferred path, for example “d:\eclipse” a. c: b+ z7 z( a; v( D& `$ {, `* X p
$ X% R) [' j) `$ f
% |$ ^* c# o- A4 e9 ?1 @7 |Create a project with Eclipse : S% q+ o! x1 |2 m
1 `+ n+ G/ i) k( P5 [
3)
+ r$ A7 l7 Q- o8 sStart the Eclipse IDE, for example “d:\eclipse\eclipse.exe”
" }- j2 B- Z' ~9 w' x' ^+ ~* ^# F& E% N+ ?* J" J/ \ a
4)/ u0 ?' @9 I( \; R% w7 m- q4 l: O
You will be asked for the location of your Workspace folder which is comparable to the MyProjects folder in Microsoft Visual Studio7 W; Y( H4 v6 m
' j8 q6 [4 g N" X* e
5)) _- c5 Z& u+ C- h2 C5 D/ @' i
Create a new Java Project by File -> New -> Java Project, G( j% j' \& H; P/ w# k$ m- D* [
6 p- `. E0 m2 d3 q% S& c
6)
% U# z7 s9 n9 t+ t/ u/ L mEnter a project name and continue with Next ?8 w- _0 } z8 R. U9 h/ X# X
- I) \. Y- N! M7 A) P
7) * F8 I( ]) |: A; Q: `% `
On the Libraries Tab add the external NXOpen Jar packages and Finish+ Q: S9 V0 h- o& G5 `, e. t! I
8 j! E8 X4 R% p d
8)
, V$ ?; W. a) U9 r& J4 }) n) t R) WIn the Package Explorer window make a right click on the project name and create a new Package (Namespace) % K& s! L- \7 g
; H; a( g& M2 e$ h/ [! `' T) b9 |% m
9)
7 u) Z8 i1 K4 p9 r: ~Enter a package name and Finish! S h+ Q# c8 H; R( u) ?5 E8 G2 e' j
( f7 c6 h1 |+ n( b; d( S5 J* K10)1 Z) {. B6 b I' t1 c& q
In the Package Explorer window make a right click on the Package name and create a new Class
" J/ i0 Q& c4 y9 `) J7 x' Q7 U0 ~3 n7 w& c t
11)
6 z4 i6 w8 k9 E( U1 C& [Enter a Class name and uncheck all method stubs options
- ^) [7 c/ f% {' g
+ g) C; J% e9 X. G9 n y3 a) a12)
: F5 ?' S$ P5 C' h8 `& y$ j4 X, `4 [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.4 N; F: g8 s- P; s6 \
First we set the NX journal language to Java by Preferences -> User Interface -> Journal -> Journal Language -> Java# t6 @0 p A8 t; D# @
7 n0 P1 k% Q# Q% I, k% @8 g
13)
6 h$ f& y5 D1 a$ \9 t$ gStart Recording by Tools -> Journal -> Record
! |$ |3 @- }2 z! M) B: y" X3 k' r& g% {4 w. `0 t7 w8 U- c
14)
- ?4 f# G5 Q: TCreate a Block and finish the journal by Tools -> Journal -> Stop Recording( Q+ b, B7 w% x. K9 r! }
4 |0 b3 U1 s& L9 r: |* Z15)# ?8 v' c' y) A `# C
Open the Journal Editor by Tools -> Journal -> Edit and copy/paste the Imports and Methods to your project source file
- h' V G4 j5 ` N1 R3 G
& \+ E' r4 u1 R0 ~! @: R% I16)0 R* G/ ? R, a4 Q2 m' v" p2 u' G6 u
Make a right click in your source window and select Source -> Format to reformat the source contents with “Eclipse rules”5 m! w6 g2 `( t! Z5 v) z: J
* u. ?- @: M* H$ q- @- u/ c
17)+ S, ^" D/ E6 b( a9 w
Finally we create the Jar file which is mandatory in case our package contains more than one class.
# T9 ~6 z, H0 E3 [9 k5 Q' ]/ SIn the Package Explorer right click on the project name and select Export -> JAR file -> Next$ g$ f: f- w; A
+ `' } v9 C, d' d$ o: Q18)' [. p7 c' v; P, j. }0 f7 S
Select the correct project, turn on Export generated class files and resources and enter the destination file name of the JAR executable.
' z/ X6 r% D7 h/ ?; b" I
3 X8 e, @" g }. e% h19)% P& V0 a( h' \$ P5 ?6 Z# X
Then proceed with Next twice, turn on Generate the manifest file, enter the Main Class and Finish
( \, ~& q7 r2 i4 L1 C w. e$ M8 T6 a
) A$ n: l- i6 P) t3 d9 \+ K9 L( R3 ZDebug the JAR or CLASS file with NX and Eclipse! J$ @& V/ H' e/ i
" U' \( k0 ]; x. _" s20)- K/ h. W. j( j1 |' U
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 .
: ]7 z" T' _7 U; K$ z6 M9 jDue 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 @) Y: d( Y+ u3 \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.
4 L* O+ J1 c4 x+ X" {7 s, g' \From a NX8 command prompt, we enter the following commands:4 r f n* H9 L: |) j& ~
' |; J# _3 L5 x( T1 ^; R. G
>set UGII_JVM_OPTIONS=-agentlib:jdwp=transport=dt_socket,address=8000,server=y,suspend=n" H6 O9 e: W {" n6 c- ?* s# [
>ugraf.exe
/ d; R' {& O( P- j
' Z/ R( J& Y7 o; F9 CThen we start the JVM once by File -> Execute -> NXOpen and selecting any *.class or *.jar file.
: I' a; }$ r, k0 s1 X9 }+ cAny simple class will do the job, for example a famous HelloWorld class.0 ^' K$ z: h. y
) o. G+ m9 n. S0 E+ L5 b! b
21)
$ T; T6 B0 [6 I2 {/ p/ ICreate the external access to the JVM session in Eclipse by Run -> Debug Configuration.4 {5 S7 r4 n9 R9 k
On the Remote Java Application node make a right click and select New
& w3 ~4 n) m+ v
% @8 b1 j) v$ z* Z. x6 l5 Q7 T4 H# V22)) B& P- x( X& I9 U2 l
Enter the Project you want to debug and make sure that the Port maTChes the address from UGII_JVM_OPTIONS
2 C$ E2 C# {. E$ y1 K$ H1 x! K% |1 i- A. ?$ h1 Y& |
23)+ m& D, d6 b& R: _
Don’t forget to set one or more breakpoints in your code where you want to interrupt execution
3 R- X0 y5 i) r& Y, L) \; p* ~- r: l ~$ ]* [: j' `1 @
24): W4 ?/ d5 e6 ?0 m* C, L" _# v
Finally execute the JAR file or CLASS file in NX that you want to debug." ]! t0 Y: ^% Q" {7 _, W
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.
; p# d5 N2 i! L! s2 O* y) o1 q) x( u& v- _0 Z& Q# M2 `5 r4 B& s. }
That's it.& c5 G T) n, G0 L6 f
|
|