SlideShare a Scribd company logo
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!

More Related Content

What's hot

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
Alex Chaffee
 
Installing the java sdk
Installing the java sdkInstalling the java sdk
Installing the java sdk
Kennedy Kiprono
 
Rcp by example
Rcp by exampleRcp by example
Rcp by example
tsubramanian80
 
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
Testplus GmbH
 
Automated Xcode 7 UI Testing
Automated Xcode 7 UI TestingAutomated Xcode 7 UI Testing
Automated Xcode 7 UI Testing
Jouni 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 wtp
odilodif
 
Installing JDK and first java program
Installing JDK and first java programInstalling JDK and first java program
Installing JDK and first java program
sunmitraeducation
 
iOS UI Testing in Xcode
iOS UI Testing in XcodeiOS UI Testing in Xcode
iOS UI Testing in Xcode
Jz 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 Testing
Bitbar
 
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 Easy
Ankit Goel
 
Android programming-basics
Android programming-basicsAndroid programming-basics
Android programming-basics
Aravindharamanan S
 
Activity
ActivityActivity
Activity
roopa_slide
 
Gwt portlet
Gwt portletGwt portlet
Gwt portlet
prabakaranbrick
 

What's hot (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 to Developing Java SWT Applications - A Starter

Java Intro: Unit1. Hello World
Java Intro: Unit1. Hello WorldJava Intro: Unit1. Hello World
Java Intro: Unit1. Hello World
Yakov 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 base
Ralf Sternberg
 
02 basic java programming and operators
02 basic java programming and operators02 basic java programming and operators
02 basic java programming and operators
Danairat Thanabodithammachari
 
Java Lab
Java LabJava Lab
Java Lab
Leo Nguyen
 
03 eclipse basics & hello world
03   eclipse basics & hello world03   eclipse basics & hello world
03 eclipse basics & hello world
Zeeshan-Shaikh
 
Unit2 java
Unit2 javaUnit2 java
Unit2 javamrecedu
 
Installation
InstallationInstallation
Installation
VenkataBolagani
 
Dspace
DspaceDspace
Jdkeclipsevs
JdkeclipsevsJdkeclipsevs
Jdkeclipsevs
NITIN BHOPALE
 
Java Programming
Java ProgrammingJava Programming
Java Programming
Anjan Mahanta
 
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
Ishara 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 IDE
Shweta Oza
 
Any point on mac
Any point on macAny point on mac
Any point on mac
Manav Prasad
 
Mc sl54 051_ (1)
Mc sl54 051_ (1)Mc sl54 051_ (1)
Mc sl54 051_ (1)
AnkitKumar2343
 
Easy java installation &amp; practice
Easy java installation &amp; practiceEasy java installation &amp; practice
Easy java installation &amp; practice
Nooria 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, JVM
manish kumar
 
java:characteristics, classpath, compliation
java:characteristics, classpath, compliationjava:characteristics, classpath, compliation
java:characteristics, classpath, compliation
Shivam Singhal
 

Similar to 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
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
Frank van Harmelen
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
DanBrown980551
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
Abida Shariff
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
Fwdays
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
Laura Byrne
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Product School
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
Safe Software
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*Neuro-symbolic is not enough, we need neuro-*semantic*
Neuro-symbolic is not enough, we need neuro-*semantic*
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptxIOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
IOS-PENTESTING-BEGINNERS-PRACTICAL-GUIDE-.pptx
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 
"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi"Impact of front-end architecture on development cost", Viktor Turskyi
"Impact of front-end architecture on development cost", Viktor Turskyi
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
The Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and SalesThe Art of the Pitch: WordPress Relationships and Sales
The Art of the Pitch: WordPress Relationships and Sales
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...Designing Great Products: The Power of Design and Leadership by Chief Designe...
Designing Great Products: The Power of Design and Leadership by Chief Designe...
 
Essentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with ParametersEssentials of Automations: Optimizing FME Workflows with Parameters
Essentials of Automations: Optimizing FME Workflows with Parameters
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 

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!