SlideShare una empresa de Scribd logo
1 de 28
Developing Java SWT Applications A Quick Start http://www.RCP-Vision.com Email: info@rcp-vision.com
SWT Applications in minutes In this short presentation we will learn how to develop and deploy  a simple SWT Application in  a matter of minutes.
Requirements The setup process however is not included in these minutes, because you will have to do some download and setting process. Anyway this is a one-time task!
Requirements Ensure you have a Java JDK installed (Java 1.5 or higher)
Download Eclipse RCP distro Go to the Eclipse download page: http://www.eclipse.org/downloads and download the RCP version of Eclipse
Extracting Eclipse RCP IDE Extract the downloaded file (e.g. “eclipse-rcp-ganymede-SR1-win32.zip”) somewhere on your local drive (e.g. on  C:) Note:  do not use the the Compressed Folder unzipper shipped with the operating system since it may not extract hidden files
Running Eclipse RCP IDE Run the Eclipse executable file  (e.g. C:clipseclipse.exe)
Running Eclipse RCP IDE Choose a workspace location
Running Eclipse RCP IDE and close the Welcome page
Create a Java Project File, New, Java Project
Create a Java Project Enter a name for the Project  (e.g. FirstSwtProject) and press the Next button
Create a Java Project Select the “Libraries” tab and press the “Add External JARs ...” button
Create a Java Project Browse and select the file <eclipse_dir>/plugins/ org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar
Create a Java Project Select the “Order and Export” tab and check the jar file we just added (this will export this jar file in the deploy phase) and press the “Finish” button
Create a Java Class Expand the Project tree, select the “src” folder and right-click New, Class
Create a Java Class Enter a package name for the new class (e.g. “com.yourcompany.swt.test”)
Create a Java Class Enter a name for the new class (e.g. “MainForm”) and make it executable  (checking “public static void main(String[] args) then press the “Finish” button
Edit the Java Class Fill the MainForm class with the following code public   class  MainForm { private   static   int   n  = 0; public   static   void  main(String[] args) { Display display =  new  Display(); Shell shell =  new  Shell(display); shell.setText( &quot;Click counter&quot; ); shell.setBounds(100, 100, 200, 100); shell.setLayout( null ); final  Label label =  new  Label(shell, SWT. PUSH ); label.setBounds(120, 20, 30, 30); final  Button button =  new  Button(shell, SWT. PUSH ); button.setBounds(10, 10, 80, 30); button.setText( &quot;Click Me&quot; ); button.addSelectionListener( new  SelectionAdapter() { public   void  widgetSelected(SelectionEvent event) { n ++; label.setText( &quot;&quot; + n ); } }); shell.open(); while  (!shell.isDisposed()) { if  (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
Edit the Java Class In order to solve the errors that are showed: right-click on the editor area and perform a “ Source, Organize imports” operation
Edit the Java Class Choose to import the SWT Button and Label class (“org.eclipse.swt.widgets.Button” and “org.eclipse.swt.widgets.Label” )
Run the Java Class Save the class (File, Save) then Right-click on the editor area and perform a “ Run as, Java Application”
Run the Java Class You should see a form with a button  and a label showing the number  of times the button was clicked
Deploy the Application Now that we have developed our (tiny) application how do we deploy it to a client ? First of all there is a requisite: on the client there must be a Java Runtime Environment installed
Deploy the Application Right-click on the Project, Export
Deploy the Application Expand the Java node,  select “Runnable JAR file”,  then press the Next button
Deploy the Application Select the (only) runnable Class
Deploy the Application Browse and enter a name for the exported JAR (e.g. C:empyFirstSWTApp.jar), then press the Finish button
Deploy the Application Ok, we are finished! Now just double-click the exported JAR file: it is your executable Java SWT Application. It can copied and launched from any client with  a Java Runtime Environment installed!

Más contenido relacionado

La actualidad más candente

Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitAlex Chaffee
 
Testing iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backendTesting iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backendTestplus GmbH
 
Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI TestingJouni Miettunen
 
React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi Binary Studio
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpodilodif
 
Installing JDK and first java program
Installing JDK and first java programInstalling JDK and first java program
Installing JDK and first java programsunmitraeducation
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in XcodeJz Chang
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingBitbar
 
Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setupChina Bigs
 
SwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made EasySwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made EasyAnkit Goel
 

La actualidad más candente (16)

Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnitWriting and Testing JavaScript-heavy Web 2.0 apps with JSUnit
Writing and Testing JavaScript-heavy Web 2.0 apps with JSUnit
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
 
 xctest
 xctest xctest
 xctest
 
Testing iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backendTesting iOS10 Apps with Appium and its new XCUITest backend
Testing iOS10 Apps with Appium and its new XCUITest backend
 
Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI Testing
 
React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi React 101 by Anatoliy Sieryi
React 101 by Anatoliy Sieryi
 
Servlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtpServlet and jsp development with eclipse wtp
Servlet and jsp development with eclipse wtp
 
Installing JDK and first java program
Installing JDK and first java programInstalling JDK and first java program
Installing JDK and first java program
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in Xcode
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App Testing
 
Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setup
 
SwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made EasySwtBot: Unit Testing Made Easy
SwtBot: Unit Testing Made Easy
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
 
Activity
ActivityActivity
Activity
 
Gwt portlet
Gwt portletGwt portlet
Gwt portlet
 

Similar a Developing Java SWT Applications - A Starter

Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldYakov Fain
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseRalf Sternberg
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello worldZeeshan-Shaikh
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 stepsIshara Amarasekera
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDEShweta Oza
 
Easy java installation &amp; practice
Easy java installation &amp; practiceEasy java installation &amp; practice
Easy java installation &amp; practiceNooria Esmaelzade
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMmanish kumar
 
java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliationShivam Singhal
 

Similar a Developing Java SWT Applications - A Starter (20)

Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
 
Java part 1
Java part 1Java part 1
Java part 1
 
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code baseSingle Sourcing RAP and RCP - Desktop and web clients from a single code base
Single Sourcing RAP and RCP - Desktop and web clients from a single code base
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
 
Javalecture 1
Javalecture 1Javalecture 1
Javalecture 1
 
Java Lab
Java LabJava Lab
Java Lab
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello world
 
Unit2 java
Unit2 javaUnit2 java
Unit2 java
 
Installation
InstallationInstallation
Installation
 
Dspace
DspaceDspace
Dspace
 
Jdkeclipsevs
JdkeclipsevsJdkeclipsevs
Jdkeclipsevs
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
How to write a simple java program in 10 steps
How to write a simple java program in 10 stepsHow to write a simple java program in 10 steps
How to write a simple java program in 10 steps
 
How to run java program without IDE
How to run java program without IDEHow to run java program without IDE
How to run java program without IDE
 
Any point on mac
Any point on macAny point on mac
Any point on mac
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
 
Easy java installation &amp; practice
Easy java installation &amp; practiceEasy java installation &amp; practice
Easy java installation &amp; practice
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
Class 1 blog
Class 1 blogClass 1 blog
Class 1 blog
 
java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliation
 

Último

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Último (20)

GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

Developing Java SWT Applications - A Starter

  • 1. Developing Java SWT Applications A Quick Start http://www.RCP-Vision.com Email: info@rcp-vision.com
  • 2. SWT Applications in minutes In this short presentation we will learn how to develop and deploy a simple SWT Application in a matter of minutes.
  • 3. Requirements The setup process however is not included in these minutes, because you will have to do some download and setting process. Anyway this is a one-time task!
  • 4. Requirements Ensure you have a Java JDK installed (Java 1.5 or higher)
  • 5. Download Eclipse RCP distro Go to the Eclipse download page: http://www.eclipse.org/downloads and download the RCP version of Eclipse
  • 6. Extracting Eclipse RCP IDE Extract the downloaded file (e.g. “eclipse-rcp-ganymede-SR1-win32.zip”) somewhere on your local drive (e.g. on C:) Note: do not use the the Compressed Folder unzipper shipped with the operating system since it may not extract hidden files
  • 7. Running Eclipse RCP IDE Run the Eclipse executable file (e.g. C:clipseclipse.exe)
  • 8. Running Eclipse RCP IDE Choose a workspace location
  • 9. Running Eclipse RCP IDE and close the Welcome page
  • 10. Create a Java Project File, New, Java Project
  • 11. Create a Java Project Enter a name for the Project (e.g. FirstSwtProject) and press the Next button
  • 12. Create a Java Project Select the “Libraries” tab and press the “Add External JARs ...” button
  • 13. Create a Java Project Browse and select the file <eclipse_dir>/plugins/ org.eclipse.swt.win32.win32.x86_3.4.1.v3449c.jar
  • 14. Create a Java Project Select the “Order and Export” tab and check the jar file we just added (this will export this jar file in the deploy phase) and press the “Finish” button
  • 15. Create a Java Class Expand the Project tree, select the “src” folder and right-click New, Class
  • 16. Create a Java Class Enter a package name for the new class (e.g. “com.yourcompany.swt.test”)
  • 17. Create a Java Class Enter a name for the new class (e.g. “MainForm”) and make it executable (checking “public static void main(String[] args) then press the “Finish” button
  • 18. Edit the Java Class Fill the MainForm class with the following code public class MainForm { private static int n = 0; public static void main(String[] args) { Display display = new Display(); Shell shell = new Shell(display); shell.setText( &quot;Click counter&quot; ); shell.setBounds(100, 100, 200, 100); shell.setLayout( null ); final Label label = new Label(shell, SWT. PUSH ); label.setBounds(120, 20, 30, 30); final Button button = new Button(shell, SWT. PUSH ); button.setBounds(10, 10, 80, 30); button.setText( &quot;Click Me&quot; ); button.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { n ++; label.setText( &quot;&quot; + n ); } }); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } display.dispose(); } }
  • 19. Edit the Java Class In order to solve the errors that are showed: right-click on the editor area and perform a “ Source, Organize imports” operation
  • 20. Edit the Java Class Choose to import the SWT Button and Label class (“org.eclipse.swt.widgets.Button” and “org.eclipse.swt.widgets.Label” )
  • 21. Run the Java Class Save the class (File, Save) then Right-click on the editor area and perform a “ Run as, Java Application”
  • 22. Run the Java Class You should see a form with a button and a label showing the number of times the button was clicked
  • 23. Deploy the Application Now that we have developed our (tiny) application how do we deploy it to a client ? First of all there is a requisite: on the client there must be a Java Runtime Environment installed
  • 24. Deploy the Application Right-click on the Project, Export
  • 25. Deploy the Application Expand the Java node, select “Runnable JAR file”, then press the Next button
  • 26. Deploy the Application Select the (only) runnable Class
  • 27. Deploy the Application Browse and enter a name for the exported JAR (e.g. C:empyFirstSWTApp.jar), then press the Finish button
  • 28. Deploy the Application Ok, we are finished! Now just double-click the exported JAR file: it is your executable Java SWT Application. It can copied and launched from any client with a Java Runtime Environment installed!