1

This question already has an answer here:

Incidentally, I have RStudio & R installed on my laptop. So I don't know why but when I double-click on .java files, they open by default in RStudio.

Every time I have to right-click and choose Sublime/Gedit as preferred choice to open these files in a proper text-editor. Can someone guide me on how to set Sublime as default for .java files(so that I can open them in Sublime with a simple double-click)?

UPDATED REQUEST: It would be much helpful if a way of doing this using terminal (or a way without using the Unity interface).

My question is partially different from How to set default program? in that I preferably need a terminal-using way.

marked as duplicate by Anwar, Android Dev, Zanna, TheWanderer, David Foerster Oct 27 '16 at 10:26

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • Please see my edited answer for the terminal way. – Android Dev Oct 26 '16 at 15:20
3

GUI Way:

  1. Right-click the file.
  2. Go to Properties
  3. Go to the "open with" tab.
  4. Select the program you want, and click Set as Default. (I don't have Sublime, so it's not in the list)

enter image description here


Terminal way:

cd into the directory containing your file and do:

mimeopen -d your-source-code.java

Sample output:

Please choose a default application for files of type text/x-java

    1) notepad  (wine-extension-txt)
    2) LibreOffice Writer  (libreoffice-writer)
    3) gedit  (gedit)
    4) Other...

use application #

Note: credit for the terminal way goes to Ugo Hed's answer here.

Not the answer you're looking for? Browse other questions tagged or ask your own question.