SlideShare a Scribd company logo
Tutorial -
Calling Java from a Bash Script
What is Bash?
Bash is a very flexible cross-platform
scripting language with multiple uses and can
integrate with lots of other tools (ie DIff). It is
built into OS X and Linux and you can
download it for Windows. This post is about
some uses of Bash and how you can use it with
Java. We will show you how we run our Java
program from Bash and hopefully give you
some ideas for how you can use Bash in your
own work.
What we use our BashScript for?
At , we specialize in converting
. This needs a LOT of regression
testing, and we use Bash to control all this. We also
use it to automate tasks as much as possible.
Recently I wrote a Bash Script (So we can run on
both Linux & Windows) to automatically pull the
required files from our FTP, convert the PDF files
used on our examples page, run PNG-Quant on them
and re-upload the converted HTML5 output to the
FTP. This way our will always show a
true representation of what our software can
currently achieve (and I can get a coffee while the
computer does all the hard work!)
IDRSolutions
examples page
PDF to HTML5
General Set up:
First things first:
You will need to visit our webkit to download our
PDF to HTML5 Trial Jar from
Next step is to create a folder anywhere you
like and move the trial jar you just
downloaded into the folder you created, for
this tutorial ours will be called example
PDF.pdf
Next create a .txt file
and name it something
like Convert PDF this is
where we will write our
BashScript
here.
Nearly all set up and good to go!
Next you will need to ensure that you have
java and PNGQuant installed:
Open Terminal and type the following line of
code:
sudo apt-get install open jdk-7-jdk open jdk-7-jre
Once you have done that next type in the
following into terminal
sudo apt-get install pngquant
Now thats all done we can get down to
writing some actual code!
Lets get coding!
Ok we are good to go and get started on writing our
BashScript.
Open up the text file that you had created with an
app such as gedit
First of all we will add the following two
lines to the top of out text file which will
tell the console that its a bash file and it
will also clear the console screen:
Coding the bash script
Now we’re going to add a variable which will hold the
location where we want our output directory (where we
want the converted files to end up) and one more
variable to hold the PDF file name.
Notice the “echo” words? They just print text to the
console, so they’re useful for documentation, giving
instructions and placing line-breaks.
Like so :
Coding the bash script
Now we will write some code which will automatically
create our OutputFile directory for us (makes our life
easier and cuts down the requirements), this is where our
converted content will end up.
Like so :
And finally the code which will run the PDFtoHTML5
jar with the input PDF file name and the output
location.
Like so :
Coding the bash script
All together your code should now look something like
this:
Giving the Scropt Permission and Running
Now we have written our BashScript to convert a PDF
file to HTML5 we need to give the file permission to run,
so first thing we do is navigate to the directory where
our .txt file is located using terminal write:
And now give our BashScript permission to run by
writing in terminal :
And now we run it..
Checking out output file
If we now check our OutputFile directory we should see
the following file which contains our html5 files
Congratulations!! In just a few lines of code you have
just converted your first PDF file to HTML5 using just a
java .jar file and some home-brewed BashScript!
As a bonus and for a bit of fun we’ll now run .png quant
over all the .png files in the converted output folder
which will reduce the file size dramatically and you can
then even host the content on your website if you
wanted to!
Running PNGQuant
Ok so once again open up the BashScript we were editing
Now add the following lines of code the bottom of the
BashScript (assuming you installed PNGQuant correctly) :
Your BashScript should finally look like this:
Running PNGQuant
Now PNGQuant will run over our converted files once they
are converted.
So finally, change the directory to where our BashScript
is located:
Run the Bash Script again
And that’s it! We have now not only written a BashScript
that will convert a PDF file to HTML5 using Java but now it
will also compress any .png images in the converted
output, thus reducing file-size!!
Follow us
www.idrsolutions.com
http://blog.idrsolutions.com
With thanks to the author:
Nathan Howard

More Related Content

What's hot

Php tutorial
Php tutorialPhp tutorial
Php tutorial
Son Nguyen
 
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
Future Processing
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
benko
 
Ruby as a glue language
Ruby as a glue languageRuby as a glue language
Ruby as a glue language
quakewang
 
Taking containers from development to production
Taking containers from development to productionTaking containers from development to production
Taking containers from development to production
Suraj Deshmukh
 
Current status of PSR - Phpblt1
Current status of PSR - Phpblt1Current status of PSR - Phpblt1
Current status of PSR - Phpblt1
Yui Sakamoto
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
d0nn9n
 
Kompose
KomposeKompose
Kompose
Suraj Narwade
 
Common Node
Common NodeCommon Node
Common Node
Oleg Podsechin
 
Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)
xSawyer
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
crazyaxe
 
Raspberry pi - Node js - Drupal
Raspberry pi - Node js - DrupalRaspberry pi - Node js - Drupal
Raspberry pi - Node js - Drupal
Mark Corben
 
Rapid API development on MongoDB
Rapid API development on MongoDBRapid API development on MongoDB
Rapid API development on MongoDB
Daniel Hjelm
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.js
Rémy Savard
 
Drupal hhvm benchmark
Drupal hhvm benchmarkDrupal hhvm benchmark
Drupal hhvm benchmark
Le Thanh Sang
 
HaXe Demo
HaXe DemoHaXe Demo
HaXe Demo
Justin Donaldson
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
James Ford
 
Run C++ as serverless with GCP Cloud Functions
Run C++ as serverless with GCP Cloud FunctionsRun C++ as serverless with GCP Cloud Functions
Run C++ as serverless with GCP Cloud Functions
Runcy Oommen
 
Creating a continuous delivery pipeline with docker
Creating a continuous delivery pipeline with dockerCreating a continuous delivery pipeline with docker
Creating a continuous delivery pipeline with docker
containershipio
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricks
Kaloyan Raev
 

What's hot (20)

Php tutorial
Php tutorialPhp tutorial
Php tutorial
 
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
[Quality Meetup #20] Michał Górski - Continuous Deployment w chmurze
 
Front-end development automation with Grunt
Front-end development automation with GruntFront-end development automation with Grunt
Front-end development automation with Grunt
 
Ruby as a glue language
Ruby as a glue languageRuby as a glue language
Ruby as a glue language
 
Taking containers from development to production
Taking containers from development to productionTaking containers from development to production
Taking containers from development to production
 
Current status of PSR - Phpblt1
Current status of PSR - Phpblt1Current status of PSR - Phpblt1
Current status of PSR - Phpblt1
 
蔡学镛 Rebol漫谈
蔡学镛   Rebol漫谈蔡学镛   Rebol漫谈
蔡学镛 Rebol漫谈
 
Kompose
KomposeKompose
Kompose
 
Common Node
Common NodeCommon Node
Common Node
 
Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)
 
Livecode widget course
Livecode widget courseLivecode widget course
Livecode widget course
 
Raspberry pi - Node js - Drupal
Raspberry pi - Node js - DrupalRaspberry pi - Node js - Drupal
Raspberry pi - Node js - Drupal
 
Rapid API development on MongoDB
Rapid API development on MongoDBRapid API development on MongoDB
Rapid API development on MongoDB
 
Devenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.jsDevenez le plus heureux des Front-end avec Gulp.js
Devenez le plus heureux des Front-end avec Gulp.js
 
Drupal hhvm benchmark
Drupal hhvm benchmarkDrupal hhvm benchmark
Drupal hhvm benchmark
 
HaXe Demo
HaXe DemoHaXe Demo
HaXe Demo
 
Grunt training deck
Grunt training deckGrunt training deck
Grunt training deck
 
Run C++ as serverless with GCP Cloud Functions
Run C++ as serverless with GCP Cloud FunctionsRun C++ as serverless with GCP Cloud Functions
Run C++ as serverless with GCP Cloud Functions
 
Creating a continuous delivery pipeline with docker
Creating a continuous delivery pipeline with dockerCreating a continuous delivery pipeline with docker
Creating a continuous delivery pipeline with docker
 
Essential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricksEssential debugging php debugging techniques, tips & tricks
Essential debugging php debugging techniques, tips & tricks
 

Viewers also liked

Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...
Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...
Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...
CLA - East
 
Permitted Development Rights for Change of use of Farm Buildings
Permitted Development Rights for Change of use of Farm BuildingsPermitted Development Rights for Change of use of Farm Buildings
Permitted Development Rights for Change of use of Farm Buildings
CLA - East
 
Is This Conversion The Right Thing To Do?
Is This Conversion The Right Thing To Do?Is This Conversion The Right Thing To Do?
Is This Conversion The Right Thing To Do?
CLA - East
 
Cap reform workshop presentation 25th march
Cap reform workshop presentation 25th marchCap reform workshop presentation 25th march
Cap reform workshop presentation 25th march
CLA - East
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
idrsolutions
 
DISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEON
DISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEONDISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEON
DISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEON
rosacarrasco1964
 
5 minute card
5 minute card5 minute card
5 minute card
Patti Hodder
 
Farm Business Update 2014: Abbots Ripton, Anglian Water and drinking water
Farm Business Update 2014: Abbots Ripton, Anglian Water and drinking waterFarm Business Update 2014: Abbots Ripton, Anglian Water and drinking water
Farm Business Update 2014: Abbots Ripton, Anglian Water and drinking water
CLA - East
 
днк
днкднк
днк
julia959
 
CAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 March
CAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 MarchCAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 March
CAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 March
CLA - East
 
Presentation up1
Presentation up1Presentation up1
Presentation up1
Anil Madhvan Pillai
 
Unit 4 my body
Unit 4 my bodyUnit 4 my body
Unit 4 my body
rozzialdana
 
Proyecto vega
Proyecto vegaProyecto vega
Proyecto vega
BioNuriaAnaArantxa
 
Its2223 bab6
Its2223 bab6Its2223 bab6
Its2223 bab6
sufiey84
 
About TASTE
About TASTEAbout TASTE
About TASTE
Kevin Longa
 
(775180194) 1 s 2015 química segundaevaluacion version cero nutricion
(775180194) 1 s 2015 química segundaevaluacion version cero nutricion(775180194) 1 s 2015 química segundaevaluacion version cero nutricion
(775180194) 1 s 2015 química segundaevaluacion version cero nutricion
Danny Riofrio Cornel
 
9 Unique Ways to Promote Your Blog Offline
9 Unique Ways to Promote Your Blog Offline9 Unique Ways to Promote Your Blog Offline
9 Unique Ways to Promote Your Blog Offline
thebookwheel
 
Consensus Conference 2013
Consensus Conference 2013Consensus Conference 2013
Consensus Conference 2013
consultanoi
 
combined_portfolio_Nov15_11x9_small
combined_portfolio_Nov15_11x9_smallcombined_portfolio_Nov15_11x9_small
combined_portfolio_Nov15_11x9_small
Michaela Strobel
 

Viewers also liked (20)

Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...
Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...
Public Rights of Way Reform and Definitive Map Modification Orders - Sarah Sl...
 
Permitted Development Rights for Change of use of Farm Buildings
Permitted Development Rights for Change of use of Farm BuildingsPermitted Development Rights for Change of use of Farm Buildings
Permitted Development Rights for Change of use of Farm Buildings
 
Is This Conversion The Right Thing To Do?
Is This Conversion The Right Thing To Do?Is This Conversion The Right Thing To Do?
Is This Conversion The Right Thing To Do?
 
Cap reform workshop presentation 25th march
Cap reform workshop presentation 25th marchCap reform workshop presentation 25th march
Cap reform workshop presentation 25th march
 
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug JavaWriting better code: How the Netbeans IDE Helps you Write, Test and Debug Java
Writing better code: How the Netbeans IDE Helps you Write, Test and Debug Java
 
DISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEON
DISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEONDISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEON
DISEÑO DE LA SECUENCIA DIDÁCTICA DE UN GIA JUAN BALDEON
 
5 minute card
5 minute card5 minute card
5 minute card
 
Farm Business Update 2014: Abbots Ripton, Anglian Water and drinking water
Farm Business Update 2014: Abbots Ripton, Anglian Water and drinking waterFarm Business Update 2014: Abbots Ripton, Anglian Water and drinking water
Farm Business Update 2014: Abbots Ripton, Anglian Water and drinking water
 
днк
днкднк
днк
 
CAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 March
CAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 MarchCAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 March
CAP Reform Workshop presentation - Strutt & Parker, Earls Colne, 24 March
 
Presentation up1
Presentation up1Presentation up1
Presentation up1
 
Unit 4 my body
Unit 4 my bodyUnit 4 my body
Unit 4 my body
 
Proyecto vega
Proyecto vegaProyecto vega
Proyecto vega
 
Its2223 bab6
Its2223 bab6Its2223 bab6
Its2223 bab6
 
About TASTE
About TASTEAbout TASTE
About TASTE
 
ㅏㅏ
ㅏㅏㅏㅏ
ㅏㅏ
 
(775180194) 1 s 2015 química segundaevaluacion version cero nutricion
(775180194) 1 s 2015 química segundaevaluacion version cero nutricion(775180194) 1 s 2015 química segundaevaluacion version cero nutricion
(775180194) 1 s 2015 química segundaevaluacion version cero nutricion
 
9 Unique Ways to Promote Your Blog Offline
9 Unique Ways to Promote Your Blog Offline9 Unique Ways to Promote Your Blog Offline
9 Unique Ways to Promote Your Blog Offline
 
Consensus Conference 2013
Consensus Conference 2013Consensus Conference 2013
Consensus Conference 2013
 
combined_portfolio_Nov15_11x9_small
combined_portfolio_Nov15_11x9_smallcombined_portfolio_Nov15_11x9_small
combined_portfolio_Nov15_11x9_small
 

Similar to Calling java from a bash script 5

COMPOSE CAMP SESSION 4.pdf
COMPOSE CAMP SESSION 4.pdfCOMPOSE CAMP SESSION 4.pdf
COMPOSE CAMP SESSION 4.pdf
AbhishekS325285
 
StdAfx.h for Novices
StdAfx.h for NovicesStdAfx.h for Novices
StdAfx.h for Novices
Andrey Karpov
 
Pig
PigPig
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for PythonwxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
Umar Yusuf
 
INTRODUCTIONS OF HTML
INTRODUCTIONS OF HTMLINTRODUCTIONS OF HTML
INTRODUCTIONS OF HTML
SURYANARAYANBISWAL1
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
tutorialsruby
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
tutorialsruby
 
LVPHP.org
LVPHP.orgLVPHP.org
LVPHP.org
Joshua Copeland
 
Appache.ppt
Appache.pptAppache.ppt
Appache.ppt
anandha ganesh
 
Introjs10.5.17SD
Introjs10.5.17SDIntrojs10.5.17SD
Introjs10.5.17SD
Thinkful
 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2
AA Coaching Academy
 
APACHE
APACHEAPACHE
APACHE
ARJUN
 
Appache.ppt
Appache.pptAppache.ppt
mush With Xampp
mush With Xamppmush With Xampp
Installing configuringdevelopingwithxampp
Installing configuringdevelopingwithxamppInstalling configuringdevelopingwithxampp
Installing configuringdevelopingwithxampp
vimalnambiar
 
DevOps Workshop Part 1
DevOps Workshop Part 1DevOps Workshop Part 1
DevOps Workshop Part 1
GDSC UofT Mississauga
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line Applications
All Things Open
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with Grunt
Ladies Who Code
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CI
Ran Bar-Zik
 
embedded report
embedded reportembedded report
embedded report
Gopikanth.M Tatavarthi
 

Similar to Calling java from a bash script 5 (20)

COMPOSE CAMP SESSION 4.pdf
COMPOSE CAMP SESSION 4.pdfCOMPOSE CAMP SESSION 4.pdf
COMPOSE CAMP SESSION 4.pdf
 
StdAfx.h for Novices
StdAfx.h for NovicesStdAfx.h for Novices
StdAfx.h for Novices
 
Pig
PigPig
Pig
 
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for PythonwxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
wxFormBuilder - Tutorial on “A GUI for making GUIs” for Python
 
INTRODUCTIONS OF HTML
INTRODUCTIONS OF HTMLINTRODUCTIONS OF HTML
INTRODUCTIONS OF HTML
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
 
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_LeopardAdding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
Adding_GD2_to_PHP_on_OS_X_Server_10_5_Leopard
 
LVPHP.org
LVPHP.orgLVPHP.org
LVPHP.org
 
Appache.ppt
Appache.pptAppache.ppt
Appache.ppt
 
Introjs10.5.17SD
Introjs10.5.17SDIntrojs10.5.17SD
Introjs10.5.17SD
 
Programming in c plus plus2
Programming in c plus plus2Programming in c plus plus2
Programming in c plus plus2
 
APACHE
APACHEAPACHE
APACHE
 
Appache.ppt
Appache.pptAppache.ppt
Appache.ppt
 
mush With Xampp
mush With Xamppmush With Xampp
mush With Xampp
 
Installing configuringdevelopingwithxampp
Installing configuringdevelopingwithxamppInstalling configuringdevelopingwithxampp
Installing configuringdevelopingwithxampp
 
DevOps Workshop Part 1
DevOps Workshop Part 1DevOps Workshop Part 1
DevOps Workshop Part 1
 
Writing Rust Command Line Applications
Writing Rust Command Line ApplicationsWriting Rust Command Line Applications
Writing Rust Command Line Applications
 
Front End Development Automation with Grunt
Front End Development Automation with GruntFront End Development Automation with Grunt
Front End Development Automation with Grunt
 
WordPress automation and CI
WordPress automation and CIWordPress automation and CI
WordPress automation and CI
 
embedded report
embedded reportembedded report
embedded report
 

Recently uploaded

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
Ivanti
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
tolgahangng
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Jeffrey Haguewood
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
Tomaz Bratanic
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
Jason Packer
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Malak Abu Hammad
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
kumardaparthi1024
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
saastr
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
innovationoecd
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Tosin Akinosho
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
Tatiana Kojar
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
ssuserfac0301
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
saastr
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Jeffrey Haguewood
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
panagenda
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
Pravash Chandra Das
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
MichaelKnudsen27
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
DanBrown980551
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
Dinusha Kumarasiri
 

Recently uploaded (20)

June Patch Tuesday
June Patch TuesdayJune Patch Tuesday
June Patch Tuesday
 
Serial Arm Control in Real Time Presentation
Serial Arm Control in Real Time PresentationSerial Arm Control in Real Time Presentation
Serial Arm Control in Real Time Presentation
 
TrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy SurveyTrustArc Webinar - 2024 Global Privacy Survey
TrustArc Webinar - 2024 Global Privacy Survey
 
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
Letter and Document Automation for Bonterra Impact Management (fka Social Sol...
 
GraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracyGraphRAG for Life Science to increase LLM accuracy
GraphRAG for Life Science to increase LLM accuracy
 
Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024Columbus Data & Analytics Wednesdays - June 2024
Columbus Data & Analytics Wednesdays - June 2024
 
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdfUnlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
Unlock the Future of Search with MongoDB Atlas_ Vector Search Unleashed.pdf
 
GenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizationsGenAI Pilot Implementation in the organizations
GenAI Pilot Implementation in the organizations
 
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStrDeep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
Deep Dive: Getting Funded with Jason Jason Lemkin Founder & CEO @ SaaStr
 
Presentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of GermanyPresentation of the OECD Artificial Intelligence Review of Germany
Presentation of the OECD Artificial Intelligence Review of Germany
 
Monitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdfMonitoring and Managing Anomaly Detection on OpenShift.pdf
Monitoring and Managing Anomaly Detection on OpenShift.pdf
 
Skybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoptionSkybuffer SAM4U tool for SAP license adoption
Skybuffer SAM4U tool for SAP license adoption
 
Taking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdfTaking AI to the Next Level in Manufacturing.pdf
Taking AI to the Next Level in Manufacturing.pdf
 
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
Overcoming the PLG Trap: Lessons from Canva's Head of Sales & Head of EMEA Da...
 
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
Salesforce Integration for Bonterra Impact Management (fka Social Solutions A...
 
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAUHCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
HCL Notes und Domino Lizenzkostenreduzierung in der Welt von DLAU
 
Operating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptxOperating System Used by Users in day-to-day life.pptx
Operating System Used by Users in day-to-day life.pptx
 
Nordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptxNordic Marketo Engage User Group_June 13_ 2024.pptx
Nordic Marketo Engage User Group_June 13_ 2024.pptx
 
5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides5th LF Energy Power Grid Model Meet-up Slides
5th LF Energy Power Grid Model Meet-up Slides
 
Azure API Management to expose backend services securely
Azure API Management to expose backend services securelyAzure API Management to expose backend services securely
Azure API Management to expose backend services securely
 

Calling java from a bash script 5

  • 1. Tutorial - Calling Java from a Bash Script
  • 2. What is Bash? Bash is a very flexible cross-platform scripting language with multiple uses and can integrate with lots of other tools (ie DIff). It is built into OS X and Linux and you can download it for Windows. This post is about some uses of Bash and how you can use it with Java. We will show you how we run our Java program from Bash and hopefully give you some ideas for how you can use Bash in your own work.
  • 3. What we use our BashScript for? At , we specialize in converting . This needs a LOT of regression testing, and we use Bash to control all this. We also use it to automate tasks as much as possible. Recently I wrote a Bash Script (So we can run on both Linux & Windows) to automatically pull the required files from our FTP, convert the PDF files used on our examples page, run PNG-Quant on them and re-upload the converted HTML5 output to the FTP. This way our will always show a true representation of what our software can currently achieve (and I can get a coffee while the computer does all the hard work!) IDRSolutions examples page PDF to HTML5
  • 4. General Set up: First things first: You will need to visit our webkit to download our PDF to HTML5 Trial Jar from Next step is to create a folder anywhere you like and move the trial jar you just downloaded into the folder you created, for this tutorial ours will be called example PDF.pdf Next create a .txt file and name it something like Convert PDF this is where we will write our BashScript here.
  • 5. Nearly all set up and good to go! Next you will need to ensure that you have java and PNGQuant installed: Open Terminal and type the following line of code: sudo apt-get install open jdk-7-jdk open jdk-7-jre Once you have done that next type in the following into terminal sudo apt-get install pngquant Now thats all done we can get down to writing some actual code!
  • 6. Lets get coding! Ok we are good to go and get started on writing our BashScript. Open up the text file that you had created with an app such as gedit First of all we will add the following two lines to the top of out text file which will tell the console that its a bash file and it will also clear the console screen:
  • 7. Coding the bash script Now we’re going to add a variable which will hold the location where we want our output directory (where we want the converted files to end up) and one more variable to hold the PDF file name. Notice the “echo” words? They just print text to the console, so they’re useful for documentation, giving instructions and placing line-breaks. Like so :
  • 8. Coding the bash script Now we will write some code which will automatically create our OutputFile directory for us (makes our life easier and cuts down the requirements), this is where our converted content will end up. Like so : And finally the code which will run the PDFtoHTML5 jar with the input PDF file name and the output location. Like so :
  • 9. Coding the bash script All together your code should now look something like this:
  • 10. Giving the Scropt Permission and Running Now we have written our BashScript to convert a PDF file to HTML5 we need to give the file permission to run, so first thing we do is navigate to the directory where our .txt file is located using terminal write: And now give our BashScript permission to run by writing in terminal : And now we run it..
  • 11. Checking out output file If we now check our OutputFile directory we should see the following file which contains our html5 files Congratulations!! In just a few lines of code you have just converted your first PDF file to HTML5 using just a java .jar file and some home-brewed BashScript! As a bonus and for a bit of fun we’ll now run .png quant over all the .png files in the converted output folder which will reduce the file size dramatically and you can then even host the content on your website if you wanted to!
  • 12. Running PNGQuant Ok so once again open up the BashScript we were editing Now add the following lines of code the bottom of the BashScript (assuming you installed PNGQuant correctly) : Your BashScript should finally look like this:
  • 13. Running PNGQuant Now PNGQuant will run over our converted files once they are converted. So finally, change the directory to where our BashScript is located: Run the Bash Script again And that’s it! We have now not only written a BashScript that will convert a PDF file to HTML5 using Java but now it will also compress any .png images in the converted output, thus reducing file-size!!