I am trying to create a Sublime Text 3 build system to compile and run my java code through the terminal on Ubuntu, not the built in window in the bottom of the Sublime window which i circled in red. The current build system I'm using is this:
{
"shell_cmd": "javac \"$file\" && java \"$file_base_name\"",
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"selector": "source.java",
}
Which works, just it doesn't open it in the terminal like i want it to. On my windows machine I use this:
{
"cmd": ["javac", "$file_name","&&","start","cmd","/k","java", "$file_base_name"],
"path":"C:\\Program Files\\Java\\jdk-11.0.3\\bin",
"shell": true
}
Which does run it in cmd, just obviously on windows not linux
This question is very similar to the following: How to set up Sublime text 3 to run and compile java on linux? which is where i got the current build system, just they wanted it to run in sublime not terminal
Here is my code for sublime in ubuntu which will popup gnome-terminal and then will execute the code there.
{
"cmd": ["javac", "$file"],
"file_regex": "^(..[^:]*):([0-9]+):?([0-9]+)?:? (.*)$",
"working_dir": "${file_path}",
"selector": "source.java",
"variants":
[
{
"name": "Run",
"shell": true,
"cmd": ["gnome-terminal -e 'bash -c \"java ${file_base_name};tput dim;tput setaf 6; echo; echo -------------------------------------------------------------------------------- ;tput sgr0;tput setaf 6;echo;echo Done Shivam now Press ENTER to continue; read line;exit; exec bash;\"'"]
}
]
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.