{"id":16782745,"url":"https://github.com/davidmoten/java-script-template","last_synced_at":"2025-04-10T22:15:45.646Z","repository":{"id":16763957,"uuid":"19521911","full_name":"davidmoten/java-script-template","owner":"davidmoten","description":"Template for a bash script that compiles and runs java commands","archived":false,"fork":false,"pushed_at":"2021-07-13T04:38:33.000Z","size":15,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-10T22:15:34.225Z","etag":null,"topics":["java","scripting"],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/davidmoten.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-05-07T05:02:47.000Z","updated_at":"2023-09-08T16:47:27.000Z","dependencies_parsed_at":"2022-08-25T11:20:33.809Z","dependency_job_id":null,"html_url":"https://github.com/davidmoten/java-script-template","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fjava-script-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fjava-script-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fjava-script-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/davidmoten%2Fjava-script-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/davidmoten","download_url":"https://codeload.github.com/davidmoten/java-script-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248305850,"owners_count":21081575,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["java","scripting"],"created_at":"2024-10-13T07:48:05.051Z","updated_at":"2025-04-10T22:15:45.310Z","avatar_url":"https://github.com/davidmoten.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"java-script-template\n====================\n\nCan you write a script with Java?\n-----------------------------------\nSo there are lots of great scripting languages out there that offer a lot over plain old shell scripting. If you know java\nthen [groovy](http://groovy.codehaus.org/) is very close and a good option but there is the alternative to write pure java by running the source with *runjava* (below) or embedding it into a bash script\n like [example.sh](https://github.com/davidmoten/java-script-template/blob/master/example.sh).\n\nHow to run java source in a separate file\n---------------------------------------------------\nIf you want to run java source in a separate file then use [runjava](https://github.com/davidmoten/java-script-template/blob/master/runjava). For example:\n\nExample.java:\n\n```java\nimport java.io.*;\nimport java.text.*;\nimport java.util.*;\n\npublic class Example {\n\n    public static void main(String[] args) throws Exception {\n       System.out.println(\"Hello \" + args[0] + \"!\");\n    }\n\n}\n```\n\nRun it like this (passing `dave` as an argument):\n\n```bash\n$ ./runjava Example.java dave\nHello dave!\n```\n\nOn my i7 desktop it takes 0.8 seconds to run (compile and execute). Same startup lag as groovy (which you would expect!).\n\nHow to embed java source in a bash script\n------------------------------------------\n[example.sh](https://github.com/davidmoten/java-script-template/blob/master/example.sh) is a bash script that has Example.java embedded in it. \nIt is designed to be run with a linux/unix bash shell.\n\nThe script is run by entering ./example.sh at the command line.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Fjava-script-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdavidmoten%2Fjava-script-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdavidmoten%2Fjava-script-template/lists"}