Industry Leader in Digital Business

Howto: Prevent multiple instances of JEdit

I recently switched to JEdit to create new PHP project, as I was having problems with my GEdit application. Though I initially liked most of the featured offered by JEdit and its various plugins, I was annoyed by the fact that every file opens in a new Window making my workspace look really messy. On the internet I could not find an solution with ease, but two articles for Linux and Windows gave me an idea on how to fix the issue on both platforms. In this article you will find the solutions I used that are based on the information found on those pages.

Microsoft Windows

Although the newer versions of JEdit automatically use one instance of JEdit to open files, there are still many people around that use older versions that open a new window every time JEdit is started or a file is opened. To prevent this behavior, you can change your JEdit-shortcut by rightclicking on the icon and selecting ‘properties’. In the screen that opens you should update the ‘target’-field to include the -reuseview parameter. On a default installation, the value should be:

{code}C:Windowssystem32javaw.exe -Xmx192M -jar “C:Program FilesjEditjedit.jar” -reuseview{/code}

In addition, you can make a batch file and use it to link your files to JEdit. First, create a file named ‘jedit.bat’ in your texteditor and enter the following lines (again modify the installation directory if you did not use the default installation path):

{code}@echo off
start “jEdit startup” “C:Windowssystem32javaw.exe” -Xmx192M -jar “C:Program FilesjEditjedit.jar” -reuseview %*{/code}

Now select one of the files that you want to associate with JEdit and rightclick on it to show its context-menu. Here you can select ‘Open with… -> Choose default program…’. In the new window you now select your batch file by clicking ‘Browse…’ to associate the filetype with JEdit.

Linux Ubuntu

In the console, execute the command sudo nano /usr/bin/jedit and change the contents of the file into the following (you might be prompted for your root password):

. /usr/lib/java-wrappers/
find_java_runtime java6
find_jars /usr/share/jedit/jedit.jar
run_java org.gjt.sp.jedit.jEdit -background -reuseview “$@”

Now the current view is reused everytime you open a new file which prevents multiple windows from popping up. In addition, the parameter -background will enable you to load JEdit faster when you close the current view (by clicking the ‘X’-button or going to ‘View -> Close View’). It actually moves JEdit to the background until you open the application again which makes sure that it shows faster when requested. Keep in mind that you mind want to remove this parameter if you are not a regular user of JEdit or if you computer does not have many resources for running applications.

Mac OS X 10.6

Juh_ posted a comment in which he explains how to implement the above solution for Mac OS X (10.6). First, open ~/bin/jedit in your favorite text editor (for example using jedit ~/bin/jedit. Now add -reuseview to the last line:

{code}exec “$JAVA_HOME/bin/java” -Xmx${JAVA_HEAP_MAX_SIZE}M -jar “/Applications/jEdit 4.4.1/jedit.jar” “-reuseview” “$@”{/code}

Related Posts

Comments (1)

Demetrius Papademetriou

Thanks for the article. This issue has been bothering me for a few months, since I changed from ubuntu 7.10 to ubuntu 11.10

Comments are closed.