Java is really jarring me1. Lame pun intended ;-)
I've just finished making a simple Swing text editor with Java and had a bit of trouble converting it into a JAR file for distribution.
The problem was that even through using the Eclipse IDE to create the file, the JAR didn't include the button icons that I was using. I eventually asked for help after unsuccessfully searching for answers myself, and found that I could only get it to work through using the console to compile the file, and indicating there that I wanted to include GIF files as well:
jar cfm TextEditor.jar MANIFEST.MF *.class *.gif
Looking at the JAR archive, the GIF files were now in there. Great!
But I ran into another problem when I tried to run the JAR. A problem that occurred when I used the console but not with Eclipse. My JAR file wouldn't even run!
I kept getting the error message "Failed to load Main-Class manifest attribute from TextEditor.jar", despite having this as my MANIFEST.MF file contents:
Manifest-Version: 1.0
Created-By: 1.6.0 (Sun Microsystems Inc.)
Main-Class: TextEditor
That looks right, doesn't it? If you're interested, the code to run the JAR file is this:
java -jar TextEditor.jar
But that wasn't working. And several google search results telling me that defining "Main-Class" would fix the problem — well, let's just say that they didn't do squat for me, because I had already done that.
Investigating further, I discovered that the MANIFEST.MF file in my JAR was missing the Main-Class line. Somewhere in the process of creating the JAR, the Manifest file was losing it's last line.
Eventually, I found the solution in this post on the Sun forums.
I'm guessing that you are developing in windows.
One diference between unix and windows' file system is that text files in unix always have a final linebreak at the end of the file, while windows doesn't need to.
Java, being developed by Sun primarily for the unix comunity requires that the manifest file ends with a new-line.
no new-line, no manifest file.
I added an extra line to the MANIFEST.MF file and suddenly everything began working as expected. One single, blank line!
I'm not going to make that mistake again! :)
Shane's Text Editor (STE v1.01)
So, what was all of this trouble for?
I was working on a text editor that uses Java's Swing components to create a GUI. Please download the file and then post a comment with the following information, to help me improve it :)
- What operating system are you using?
- Did the application work correctly? If not, what error messages did you see?
- If you are using Windows XP or a Mac, please upload screen shots! (I don't have either of those)
- Do you have any suggestions for improvements (or things that should be moved/removed)?
- If you're nifty with Photoshop, are you willing to create some icons and a logo for a Wikidot-oriented version of this?
Download: STE-1-01.jar 21.15 kB
Edit: Updated the file to v1.01
1. What operating system are you using?
2. Did the application work correctly? If not, what error messages did you see?
3. If you are using Windows XP or a Mac, please upload screen shots! (I don't have either of those)
4. Do you have any suggestions for improvements (or things that should be moved/removed)?
5. If you're nifty with Photoshop, are you willing to create some icons and a logo for a Wikidot-oriented version of this?
Not a bad start. I'm interested to see where this goes.
-Ed
Community Admin
More than two years later… I'm pretty happy with where it led :)
This tiny little editor eventually grew into STE 3.50, and is the reason I'm now working on STE 4.00
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Thanks for the screenshot :)
Not sure how to do the multi-tabbed interface. I can create multiple tabs, but the problem is finding a way to keep everything separate… I'd likely only be able to open one file and show it in all tabs (which isn't very useful!) with my current knowledge of Java. Will have to look into it.
Word wrap I'll definitely fix in the next version. Menu option + enabled by default are two things that I can easily do and I agree, are worth doing.
File extension filters should be easy enough — I'm not sure how to do it but suspect it will just be a couple of lines of code, as I've done something similar in C# (just not in Java). Will look into that soon. In fact, I was planning to do this, and to create a new extension *.ste for these files, after I add in Wikidot syntax detection of some kind.
Edit (icons): As for the icons, I was thinking that some buttons that were similar in appearance to the editor buttons above text fields would be great - but with open/save options instead of H1 / link wizard / etc. There should be both a 24x24 and a 16x16 version of each icon, and the backgrounds should be transparent (save as .gif)
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Multi-tab is not that big of a deal, especially since we can run multiple instances.
Are you calling the system file dialog or is the open/save dialog something you wrote? One thing I noticed is that I didn't have the usual options available to me when opening a file like rename, delete, etc.
One more option that I found that was missing is a prompt to save if I try to exit after editing the file. You can probably accomplish that by simply setting a flag if any edit action is taken and then check the state of that flag before exiting.
Do you have a list of button functions you want to create graphics for?
Community Admin
I'm creating the new website for this, to replace the old one. Will reply to your post there, as soon as I've set up the forums.
~ Leiger - Wikidot Community Admin - Volunteer
Wikidot: Official Documentation | Wikidot Discord server | NEW: Wikiroo, backup tool (in development)
Post preview:
Close preview