SlideShare a Scribd company logo
Jython
Python for Java Platform
Agenda
❖ History
❖ Introduction
❖ Installation
❖ Jython Console
❖ Jython Basic Datatypes
❖ Collections
❖ Modules and Importing
❖ Functions
History
It was initially created in late 1997 to replace C with Java for performace
intensive.
It moves to SourceForge in October, 2000.
The Python Software Foundation awarded a grant in January 2005.
Jython 2.5 was released in June 2009
Introduction
● Python is an easy to learn, powerful programming language.
● Jython is an implementation of Python for the JVM.
● It takes the Python programming languages syntax and enables it to run
on the Java Platform.
● Most of the Python modules will run without changes under Jython, but if
they use extensions then they will probably not work.
Why Jython
1. Embedded Scripting
2. Ability to extend existing Java classes
3. Optional static compilation
4. Bean Properties
5. Python Language
There are certain libraries written in Java languages to be included with Jython
(especially modules written in C).
● Introduction
● Built-in Functions
● Built-in Constants
● Built-in Objects
● Built-in Types
● Built-in Exceptions
● String Services
● Data Types
● Numeric and Mathematical
Modules
● File and Directory Access
● Data Persistence
● Data Compression and
Archiving
● File Formats
● Cryptographic Services
● Generic Operating System
Service
● Optional Operating System
● Interprocess Communication
and Networking
● Many More...
Installation
Download Jython 2.7 and execute below command to start installation GUI.
java -jar jython_installer-2.*.*.jar
We can add --console to start the installation in non GUI.
JYTHON_HOME=/home/vijay/jython2.7.0; export JYTHON_HOME
PATH=$PATH:$JYTHON_HOME/bin
Jython
Jython-Introduction
Jython Basic Data Type
● It sees everything, including all data and code, as an object.
● Jython Types Summary
● Common Operators
● Boolean Types
● Numeric Types
● Additional Methods and Operations
Jython Collections
It supports two major types of collections
1. Sequence Types (Order Collection of items)
2. Map Type
Sequence Types
1. All sequences are zero-indexed. It is similar to C and Java Arrays.
2. All sequences support indexing (or subscripting) to select sub-elements.
3. It support an extension of indexing, called slicing, which selects a range of
elements.
4. It also support reverse slicing.
5. Slicing Reference
6. Sequence Operators
7. Sequence Function
Strings
1. A string is an immutable sequence of characters treated as a value.
2. String Methods
3. It doesn’t have a character type. Character are represented by strings of
length one.
4. Escape Character
5. Format Code
Tuples
1. Tuples are immutable lists of any type.
2. It can be of any length and can contain any type of object.
3. Tuple Example
Ranges
1. Jython uses immutable sequence of increasing integers, called ranges.
2. It can be easily created by
a. range({start}, end,{inc}) creates a small range. All element of the range exist.
b. xrange({start}, end, {inc}) creates a large range. Elements are created only as needed.
3. Default start is 0 and default inc is 1.
Lists
1. Lists Method
2. We can use List as Stack and Queue.
3. Stack is easy to implement using append() and pop().
4. To implement Queue we use collections.queue
5. It can also be created via advance notation, called list comprehensions.
Map and Dictionaries
We work only with subtypes of Map. Most commonly we used dictionary.
Dictionary Example
Jython-Introduction
Modules and Importing
● Jython breaks program down into separate files, called modules.
● Jython Modules Library
● A module is an executable Jython file that contains definitions.
● Jython packages are implemented as directories that can contain one or
more than one modules and a special file __init__.py, that executed before
first module of the package is executed.
● import module {as alias} OR from module import name {as alias}
● From module import *
● Import is executable
Math Module Examples
Other Important Stuff
Exception
Procedural Statement
Jython Functions
1. Functions
Blocks of code that return values (called functions)
2. Subroutines
Blocks that don’t return values
Functions are declared by def statement.
def name ( args ): statement -- or -- def name ( args ): block
● Specifying Function Argument
● Anonymous Function
● Generic Function
● Nested Function
● Functional Programming
Sample Application
Jython-Introduction
References
● http://imagej.net/Jython_Scripting_Examples
● https://www.ibm.com/developerworks/java/tutorials/j-jython1/j-jython1.h
tml
● https://dzone.com/articles/embed-jython-to-your-java-codebase

More Related Content

PPTX
Programming in python - Week 7,8
PDF
Linux Internals - Part III
PDF
Javainterview
PPTX
MULTI THREADING IN JAVA
PPTX
Java applet
PPT
Core Java interview questions-ppt
DOCX
Interview Questions and Answers for Java
PPTX
Chapter 03 python libraries
Programming in python - Week 7,8
Linux Internals - Part III
Javainterview
MULTI THREADING IN JAVA
Java applet
Core Java interview questions-ppt
Interview Questions and Answers for Java
Chapter 03 python libraries

What's hot (18)

PPT
Developing Multithreaded Applications
PDF
Review of c_sharp2_features_part_iii
DOC
Core java questions
PPT
Java Threads and Concurrency
PPT
12 multi-threading
 
PDF
Java threads
PPTX
Multithreading in java
PDF
Threads concept in java
PPTX
Multithreading in java
PPTX
Thread model of java
PPTX
L22 multi-threading-introduction
PPT
Thread model in java
PPT
Synchronization.37
DOC
Java interview questions
PDF
Java Interview Questions by NageswaraRao
ODP
Multithreading In Java
PPTX
Multithread Programing in Java
Developing Multithreaded Applications
Review of c_sharp2_features_part_iii
Core java questions
Java Threads and Concurrency
12 multi-threading
 
Java threads
Multithreading in java
Threads concept in java
Multithreading in java
Thread model of java
L22 multi-threading-introduction
Thread model in java
Synchronization.37
Java interview questions
Java Interview Questions by NageswaraRao
Multithreading In Java
Multithread Programing in Java
Ad

Similar to Jython-Introduction (20)

PDF
python interview prep question , 52 questions
PPTX
Python intro
KEY
Programming with Python: Week 1
PPTX
Docketrun's Python Course for beginners.pptx
PDF
Python Course In Chandigarh
PDF
web programming Unit VIII complete about python by Bhavsingh Maloth
PPTX
Python Demo.pptx
PPTX
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
PDF
Chapter 2 Python Language Basics, IPython, and Jupyter Notebooks.pdf
PDF
Python Course In Chandigarh
PDF
Unit-2 Introduction of Modules and Packages.pdf
DOCX
Python Interview Questions For Experienced
PPTX
Functions in Python
PPTX
Python Demo.pptx
PPTX
Python UNIT-IV Multi Threading B.Tech CSE
PDF
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
PDF
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
ODP
Java 9 Features
python interview prep question , 52 questions
Python intro
Programming with Python: Week 1
Docketrun's Python Course for beginners.pptx
Python Course In Chandigarh
web programming Unit VIII complete about python by Bhavsingh Maloth
Python Demo.pptx
Python Mastery: A Comprehensive Guide to Setting Up Your Development Environment
Chapter 2 Python Language Basics, IPython, and Jupyter Notebooks.pdf
Python Course In Chandigarh
Unit-2 Introduction of Modules and Packages.pdf
Python Interview Questions For Experienced
Functions in Python
Python Demo.pptx
Python UNIT-IV Multi Threading B.Tech CSE
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
20210517-PYTHON AI&DS PROGRAMMING NOTES.pdf
Java 9 Features
Ad

Recently uploaded (20)

PPTX
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
PPTX
oil_refinery_comprehensive_20250804084928 (1).pptx
PPTX
Database Infoormation System (DBIS).pptx
PPTX
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
PDF
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
PPTX
Introduction to machine learning and Linear Models
PPTX
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
PPT
ISS -ESG Data flows What is ESG and HowHow
PPT
Miokarditis (Inflamasi pada Otot Jantung)
PDF
Business Analytics and business intelligence.pdf
PDF
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
PPTX
Supervised vs unsupervised machine learning algorithms
PDF
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
PPTX
Business Ppt On Nestle.pptx huunnnhhgfvu
PDF
Lecture1 pattern recognition............
PPTX
Business Acumen Training GuidePresentation.pptx
PPTX
Data_Analytics_and_PowerBI_Presentation.pptx
PPTX
Introduction to Knowledge Engineering Part 1
PPTX
IBA_Chapter_11_Slides_Final_Accessible.pptx
PPTX
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb
01_intro xxxxxxxxxxfffffffffffaaaaaaaaaaafg
oil_refinery_comprehensive_20250804084928 (1).pptx
Database Infoormation System (DBIS).pptx
The THESIS FINAL-DEFENSE-PRESENTATION.pptx
TRAFFIC-MANAGEMENT-AND-ACCIDENT-INVESTIGATION-WITH-DRIVING-PDF-FILE.pdf
Introduction to machine learning and Linear Models
Introduction to Firewall Analytics - Interfirewall and Transfirewall.pptx
ISS -ESG Data flows What is ESG and HowHow
Miokarditis (Inflamasi pada Otot Jantung)
Business Analytics and business intelligence.pdf
BF and FI - Blockchain, fintech and Financial Innovation Lesson 2.pdf
Supervised vs unsupervised machine learning algorithms
22.Patil - Early prediction of Alzheimer’s disease using convolutional neural...
Business Ppt On Nestle.pptx huunnnhhgfvu
Lecture1 pattern recognition............
Business Acumen Training GuidePresentation.pptx
Data_Analytics_and_PowerBI_Presentation.pptx
Introduction to Knowledge Engineering Part 1
IBA_Chapter_11_Slides_Final_Accessible.pptx
mbdjdhjjodule 5-1 rhfhhfjtjjhafbrhfnfbbfnb

Jython-Introduction

  • 2. Agenda ❖ History ❖ Introduction ❖ Installation ❖ Jython Console ❖ Jython Basic Datatypes ❖ Collections ❖ Modules and Importing ❖ Functions
  • 3. History It was initially created in late 1997 to replace C with Java for performace intensive. It moves to SourceForge in October, 2000. The Python Software Foundation awarded a grant in January 2005. Jython 2.5 was released in June 2009
  • 4. Introduction ● Python is an easy to learn, powerful programming language. ● Jython is an implementation of Python for the JVM. ● It takes the Python programming languages syntax and enables it to run on the Java Platform. ● Most of the Python modules will run without changes under Jython, but if they use extensions then they will probably not work.
  • 5. Why Jython 1. Embedded Scripting 2. Ability to extend existing Java classes 3. Optional static compilation 4. Bean Properties 5. Python Language
  • 6. There are certain libraries written in Java languages to be included with Jython (especially modules written in C). ● Introduction ● Built-in Functions ● Built-in Constants ● Built-in Objects ● Built-in Types ● Built-in Exceptions ● String Services ● Data Types ● Numeric and Mathematical Modules ● File and Directory Access ● Data Persistence ● Data Compression and Archiving ● File Formats ● Cryptographic Services ● Generic Operating System Service ● Optional Operating System ● Interprocess Communication and Networking ● Many More...
  • 7. Installation Download Jython 2.7 and execute below command to start installation GUI. java -jar jython_installer-2.*.*.jar We can add --console to start the installation in non GUI. JYTHON_HOME=/home/vijay/jython2.7.0; export JYTHON_HOME PATH=$PATH:$JYTHON_HOME/bin
  • 10. Jython Basic Data Type ● It sees everything, including all data and code, as an object. ● Jython Types Summary ● Common Operators ● Boolean Types ● Numeric Types ● Additional Methods and Operations
  • 11. Jython Collections It supports two major types of collections 1. Sequence Types (Order Collection of items) 2. Map Type
  • 12. Sequence Types 1. All sequences are zero-indexed. It is similar to C and Java Arrays. 2. All sequences support indexing (or subscripting) to select sub-elements. 3. It support an extension of indexing, called slicing, which selects a range of elements. 4. It also support reverse slicing. 5. Slicing Reference 6. Sequence Operators 7. Sequence Function
  • 13. Strings 1. A string is an immutable sequence of characters treated as a value. 2. String Methods 3. It doesn’t have a character type. Character are represented by strings of length one. 4. Escape Character 5. Format Code
  • 14. Tuples 1. Tuples are immutable lists of any type. 2. It can be of any length and can contain any type of object. 3. Tuple Example
  • 15. Ranges 1. Jython uses immutable sequence of increasing integers, called ranges. 2. It can be easily created by a. range({start}, end,{inc}) creates a small range. All element of the range exist. b. xrange({start}, end, {inc}) creates a large range. Elements are created only as needed. 3. Default start is 0 and default inc is 1.
  • 16. Lists 1. Lists Method 2. We can use List as Stack and Queue. 3. Stack is easy to implement using append() and pop(). 4. To implement Queue we use collections.queue 5. It can also be created via advance notation, called list comprehensions.
  • 17. Map and Dictionaries We work only with subtypes of Map. Most commonly we used dictionary. Dictionary Example
  • 19. Modules and Importing ● Jython breaks program down into separate files, called modules. ● Jython Modules Library ● A module is an executable Jython file that contains definitions. ● Jython packages are implemented as directories that can contain one or more than one modules and a special file __init__.py, that executed before first module of the package is executed. ● import module {as alias} OR from module import name {as alias} ● From module import * ● Import is executable
  • 22. Jython Functions 1. Functions Blocks of code that return values (called functions) 2. Subroutines Blocks that don’t return values Functions are declared by def statement. def name ( args ): statement -- or -- def name ( args ): block
  • 23. ● Specifying Function Argument ● Anonymous Function ● Generic Function ● Nested Function ● Functional Programming