SlideShare uma empresa 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!

Mais conteúdo relacionado

Mais procurados

Eclipse & android setup
Eclipse & android setupEclipse & android setup
Eclipse & android setup
China Bigs
 

Mais procurados (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
 

Semelhante a Developing Java SWT Applications - A Starter

Unit2 java
Unit2 javaUnit2 java
Unit2 java
mrecedu
 

Semelhante 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

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
vu2urc
 

Último (20)

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?
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
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
 
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
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
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
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
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...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 

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!