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

  • Home
  • SEARCH
  • 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 6370429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:55:46+00:00 2026-05-25T00:55:46+00:00

After creating a uberjar with leiningen, and running the jar with java -jar foo-uberjar.jar

  • 0

After creating a uberjar with leiningen, and running the jar with java -jar foo-uberjar.jar the program runs fine, and the last line of code is executed quite fast, but the program hangs for about a minute before shutting down. What is the cause of this?

(ns redditwallpaper.core
  (:gen-class)
  (:require [clojure.contrib.duck-streams :as duck]
            [clojure.java [io :as io] [shell :as shell]]
            [clojure.string :as string]
            [clojure.contrib.json :as json])
  (:import (java.util Random)))

(defn filename [uri]
  (last (string/split uri #"/")))
(defn over_18 [x]
  (:over_18 x))
(defn posts [x]
  (map :data (get-in x [:data :children])))
(defn plain-image [x]
  (re-find #"(.jpg|.png)$" (:url x)))
(def url "http://www.reddit.com/r/wallpaper.json")
(def wallpaperjson (json/read-json (slurp url)))
(defn copy [uri fname]
  (with-open [in (io/input-stream uri)
              out (io/output-stream fname)]
    (.write out (duck/to-byte-array in))))
(defn randrange [n]
  (.nextInt (Random.) n))
(defn randitem [xs]
  (let [n (count xs)]
    (nth xs (randrange n))))
(defn set-background [file]
  (shell/sh "feh" "--bg-scale" file))
(defn -main [& args]
  (let [posts (posts wallpaperjson)
        safe (filter (complement over_18) posts)
        images (filter plain-image safe)
        image (:url (randitem images))
        fname (filename image)]
    (do
      (println (format "Downloading '%s'" image))
      (copy image fname)
      (println (format "Setting background image to '%s'" fname))
      (set-background fname)
      (println "Done"))))

java -jar redditwallpaper-0.0.1-standalone.jar 2.71s user 0.34s system 4% cpu 1:03.15 total

  • 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-05-25T00:55:47+00:00Added an answer on May 25, 2026 at 12:55 am

    Try adding,

    (shutdown-agents)
    

    when you are ready to exit.

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

Sidebar

Related Questions

nimbus look and feel not appear after creating jar when i run program in
After creating a new object (Foo), I set the key (BarId) for an EntityRef
I try to run one program in myeclipse where after creating one web project
after creating some menus with simple_list_item_1 (which worked very fine) I tried to replace
I have some code that adds to a std::vector and a std::map after creating
After creating large objects and running out of RAM, I will try and delete
After creating a mvc 3 web site using code first & adding same date
The problem is that the program throws an exception. After creating multiple threads. How
After creating a instance of a class, can we invoke the constructor explicitly? For
After creating a new form, I usually perform this ritual: Change the name into

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.