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

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilV3cube
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
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
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
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
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
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
 

Último (20)

Developing An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of BrazilDeveloping An App To Navigate The Roads of Brazil
Developing An App To Navigate The Roads of Brazil
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 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...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
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
 
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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
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...
 

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!