Skip to content

Instantly share code, notes, and snippets.

@CarloRamponi
Last active January 14, 2017 10:50
Show Gist options
  • Save CarloRamponi/e9dc13b941e744943746252c1d39c450 to your computer and use it in GitHub Desktop.
Save CarloRamponi/e9dc13b941e744943746252c1d39c450 to your computer and use it in GitHub Desktop.
This script creates a java projects and create the make file for the Atom plugin "Project Runner" so that when you press CTRL+R it will compile, and CTRL+U it will compile and run the project, .java file must be put into the src directory, .class will be put in bin directory
#This script creates a java projects and create the make file for the Atom plugin "Project Runner"
#to install "ProjectRunner: apm install project-runnaer"
#and it will open atom in the project directory
#so that when you press CTRL+R it will compile, and CTRL+U it will compile and run the project,
#.java file must be put into the src directory, .class will be put in bin directory.
#Usage: javaProject path/to/project NameOfTheClass
#!/bin/bash
if [ "$1" == "" ] || [ "$2" == "" ]; then
echo "Usage: javaProject /path/to/project name"
exit 1;
fi
if [ -d "$1" ]; then
echo -e "Directory:\n\t$1\nalready exists!"
exit 1
fi
mkdir -p $1/
mkdir $1/src
mkdir $1/bin
echo -e "public class $2{\n\n\tpublic static void main(String args[]){\n\n\t\tSystem.out.println(\"Hello World !\");\n\n\t}\n\n}" > $1/src/$2.java
echo -e "all:\n\tjavac -d bin src/*.java\n\ntest:\n\tjavac -d bin src/*.java\n\tcd bin; java $2\n\n" > $1/Makefile
atom $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment