Associating Files With jEdit
Submitted by Monday, 20 August, 2007 - 18:07
on
I really like using jEdit. It is a wonderful piece of software.
But with version 4.2 there is no way to associate file types with jEdit.
I was looking for a way to associate file types with jEdit in Windows.
Windows will not let you associate an executeable ".jar" file with a file type.
I like the function in windows of just double clicking on the file name and
having the file load in a particular application. When a file is double clicked
in Windows the file name is passed to the program associated with that file.
From some simple testing I knew that jEdit would accept a command line argument
with the file name in it. So all you have to do is create a simple executeable
file that will pass its command line arguments to jEdit and load jEdit. I did
this using Visual Studio 2005.
Create a new windows application and name it "jEdit".
Make the Icon for the executeable
In the Solution Explorer right click on the jEdit project and select
"Properties".
In the main screen on the left hand tab section choose the "Application"
tab.
Under icon browse to the jEdit icon saved wherever jEdit was installed on
your computer.
Add this code in the form load event
Try
Dim jFile As String = ""
If My.Application.CommandLineArgs.Count = 0 Then
'There are no command line arguments
'So there is no File Name supplied
'Will just load Jedit when .exe is double clicked
jFile = Nothing
Else
'A file associated with this appliction is doubled clicked
'The file name is passed in the first command line argument
'Enclose filename in quotation marks in case of spaes in file name
jFile = Chr(34) & My.Application.CommandLineArgs.Item(0) & Chr(34)
End If
Dim applicationName As String = "C:\Program Files\jEdit\jedit.jar"
Dim jProcess As New System.Diagnostics.Process
jProcess.StartInfo.FileName = applicationName
jProcess.StartInfo.Arguments = jFile
jProcess.Start()
jProcess.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "jEdit Load Error")
End Try
Me.Visible = False
Me.Close()
The "C:\Program Files\jEdit\jedit.jar" is installation location for the jEdit
executeable. So change this as necessary.
Build the project
Navigate to the Visual Studio 2005 project folder for the jEdit project you
created and locate the executeable created after the build.
Save the ".exe" in the jEdit installation directory.
You now have a "jEdit.exe" that you can associate file types too.
But with version 4.2 there is no way to associate file types with jEdit.
I was looking for a way to associate file types with jEdit in Windows.
Windows will not let you associate an executeable ".jar" file with a file type.
I like the function in windows of just double clicking on the file name and
having the file load in a particular application. When a file is double clicked
in Windows the file name is passed to the program associated with that file.
From some simple testing I knew that jEdit would accept a command line argument
with the file name in it. So all you have to do is create a simple executeable
file that will pass its command line arguments to jEdit and load jEdit. I did
this using Visual Studio 2005.
Create a new windows application and name it "jEdit".
Make the Icon for the executeable
In the Solution Explorer right click on the jEdit project and select
"Properties".
In the main screen on the left hand tab section choose the "Application"
tab.
Under icon browse to the jEdit icon saved wherever jEdit was installed on
your computer.
Add this code in the form load event
Try
Dim jFile As String = ""
If My.Application.CommandLineArgs.Count = 0 Then
'There are no command line arguments
'So there is no File Name supplied
'Will just load Jedit when .exe is double clicked
jFile = Nothing
Else
'A file associated with this appliction is doubled clicked
'The file name is passed in the first command line argument
'Enclose filename in quotation marks in case of spaes in file name
jFile = Chr(34) & My.Application.CommandLineArgs.Item(0) & Chr(34)
End If
Dim applicationName As String = "C:\Program Files\jEdit\jedit.jar"
Dim jProcess As New System.Diagnostics.Process
jProcess.StartInfo.FileName = applicationName
jProcess.StartInfo.Arguments = jFile
jProcess.Start()
jProcess.Close()
Catch ex As Exception
MessageBox.Show(ex.Message, "jEdit Load Error")
End Try
Me.Visible = False
Me.Close()
The "C:\Program Files\jEdit\jedit.jar" is installation location for the jEdit
executeable. So change this as necessary.
Build the project
Navigate to the Visual Studio 2005 project folder for the jEdit project you
created and locate the executeable created after the build.
Save the ".exe" in the jEdit installation directory.
You now have a "jEdit.exe" that you can associate file types too.