Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8926493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T07:59:04+00:00 2026-06-15T07:59:04+00:00

I am using jhead to check if an image has an Orientation flag set,

  • 0

I am using jhead to check if an image has an Orientation flag set, and if it is, then rotate it and set the exif information to indicate it does not need to be rotated when viewed. On the commandline it looks like:

jhead -autorot 'IMG_3680.JPG'

I am trying to use ProcessBuilder to call this from my java app on the images I am looking at, but it uses jpegtran to do the actual image rotation. Both these apps work correctly from the commandline and are located in /opt/local/bin on my mac.

I keep getting:

sh: jpegtran: command not found

Error : Problem executing specified command
in file '/images/IMG_3681.JPG'

My code is:

public static void main(String[] args) throws Exception {

    File[] files = (new File("/images")).listFiles();
    for (File file : files){
      ProcessBuilder pb = new ProcessBuilder("jhead", "-autorot", file.getAbsolutePath());
      pb.redirectOutput(Redirect.INHERIT);
      pb.redirectError(Redirect.INHERIT);
      Process p = pb.start();
    }
}

Do I need to provide a hint to ProcessBuilder in order for jhead to be able to call jpegtran?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T07:59:05+00:00Added an answer on June 15, 2026 at 7:59 am

    After some guess work, I determined that the PATH environment variable was not set correctly. It had /usr/bin:/bin:/usr/sbin which obviously does not include /opt/local/bin. I added it like so:

    Map<String, String> env = pb.environment();
    env.put("PATH", env.get("PATH")+":/opt/local/bin/");
    

    Which now produces the correct result. The real solution though is to add /opt/local/bin/ to the PATH environment variable and not add this in the code directly.


    UPDATE: After some more looking it seems this would not have been a problem if I ran my app from Terminal instead of Eclipse. The PATH variable is set correctly in Terminal, but I had to add it to Eclipse. To add it to Eclipse:

    1. Goto Run -> Run Configurations -> Environment
    2. Click new and for the Name enter PATH and Value enter /usr/bin:/bin:/usr/sbin:/sbin:/opt/local/bin/
    3. Click Apply.

    If you do need to set this in OS X then there seems to be a few ways (or really a few places). If you need it for applications that are launched via Spotlight then go here. If you need to set if for Terminal than go here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using the opencart image manager how would I set the upload to automatically remove:
Using the Exiv2 library to write some exif tags to an image i'm running
Using a CSS image sprite, I'm creating an 'interactive' image where hovering over certain
Using php/html, I want to retrieve email addresses (plus other information) from MySQL and
Using TortoiseSVN against VisualSVN I delete a source file that I should not have
Using JDeveloper , I started developing a set of web pages for a project
Using C#, I need a class called User that has a username, password, active
Using PyGtk's IconView, I can set the icons to be reorderable by calling gtk.IconView.set_reorderable(True)
Using Yii, I want to delete all the rows that are not from today.
Using EF Code First I have an model object that has multiple properties that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.