Proposed feature set
- 2d draw mode
- edit xml mode
- 3d mode with vtk
- Add lines/members
- mirror
- copy
- offset
- trim
- rotate
- ortho
Naked somethin' somethin' for Earthquake Engineering Simulation
cd java/mkdir classes/javac -d classes/ vtk/*.javacd classes/jar cvf vtk.jar vtk/jar i vtk.jarcp vtk.jar ../../bin/Manifest-Version: 1.0
Main-Class: nakedsees.swt.MainDisplay
Class-Path: ./libraries/swt.jar
classes
..\jre\bin\NakedSees.exe
-Djava.library.path=./native/ -jar nakedsees.jar
When building a client side Java application, with whatever GUI Framework happens to be your favourite one (AWT, Swing, SWT - just to name the obvious triplet), at some point you really have got to ask yourself what would be the best way to distribute your app, without causing the end-user too much pain.
I think that most people would agree that customer acceptance depends to a large extent on the first impression of the user with the particular product. The first contact with your software however, typically is the installation procedure. With java software and the advent of so called "Platform independent" solutions various attempts to address installation facilities have been tried, but just too often, java coders tend to neglect this duty shamefully. Pretty often you find yourself with some classes and jar files you need to copy all over your system, add extensions to your classpath and finally launch the app from the command line via :java classname just to watch it fail a dozen times before you discover that you forgot to add the -Djava.library.path property to the command line (as stated in the readme.txt at line 1846).
The Installer
Windows users can be very choosey about standardized installation procedures, thus I would recommend using a native Windows Installer like the Nullsoft Install System to create an installer (i.e. a Setup.exe) for your application that can be installed and uninstalled properly in a standard, Windows waytm. NSIS offers a pretty cool, powerful macro language for installers that you fortunately don't really have to learn to create your typical basic installer. For the average installer it is sufficient to use the really cool wizard option of the magnificent open source Installer editor HM NIS Edit by Hector Mauricio Rodriguez Segura and just take your setup.exe and go. You can easily build really complex installers with custom controls with this tool as well - sky's the limit.
Launching the app
Launching your java application is the next experience the user comes in contact with. If you choose to launch your application through some batch files or worse, let the user start the app through command line as mentioned above, you will most definitely burn in coder hell - and rightly so. There are quite a number of really useful java launchers out there that make launching a java app no less pain than a double click, though the application may actually have serious amounts of dependencies. My favourite one is the Marner Java Launcher by Jacob Marner. It is basically a small executable program written in C, that launches your java VM with all your previously configured options.
Let's assume following example: You wrote a small app that uses a couple of java libraries and utilises the Eclipse SWT framework for the GUI. Now you want the java launcher to do all your bidding. Your first step should be to create a folder at the root of your project directory called libraries and copy jface.jar, swt.jar and whatever libraries you desire into it. Also, you should copy the native SWT dlls into a separate folder called native. In our case this would be swt-awt-win32-xxxx.dll and swt-win32-xxxx.dll from the eclipse directory eclipse\plugins\org.eclipse.swt.win32_x.x.x\os\win32�. Now we have gathered our source code, the dependent libraries and the native components in one directory.
Now we should create a jar file from our source code that contains a file in the root directory called manifest.mf file. The manifest.mf file contains information which Class should be launched as an entry point into our application (i.e. which class contains the main() method. Also it adds our dependent libraries from the libraries folder to our classpath. The manifest.mf file should look like this:
Manifest-Version: 1.0
Main-Class: de.keyboardsamurais.ApplicationMain
Class-Path: ./libraries/xmlrpc-1.2-b1.jar ./libraries/jface.jar ./libraries/log4j-1.2.8.jar ./lib/swt.jar
Eclipse Users can use the "Export" feature for the jar packaging. Now we are able to call our class from the command line via the call java -jar application.jar. Well...almost! Our application still lacks the native DLL components, so we need to tell the VM where they can be found via a -D flag. We can enter java -Djava.library.path=./native/ -jar application.jar and our app should run flawlessly.
Now, that's the point where we configure the launcher.cfg file from our java launcher. For our example this config file would look like that:
.
javaw.exe
-Djava.library.path=./native/ -jar application.jar
If you do need an output window for log messages you can exchange javaw.exe for java.exe. You can now click on the Launcher.exe (which you should have copied into your project directory by now) and your application will run like a charm.
You can now wrap it all up into a nice installer and everybody will have a pleasant experience with your software deployment. You might want to change the icon of your launcher.exe to something more fitting. I recommend doing this with Resource Hacker by Angus Johnson.
Last words
Be aware that there are more than a few other options to do all of the above mentioned steps. One of the most promising install systems is Java WebStart and there are a couple of multi platform installers that promise "Write once, run anywhere". However I am quite happy with the above solution.
by Jacob Marner. (jacob@marner.dk)
Java is a great programming language, but it is generally somewhat complex for novice end-users to get the program up running. Traditionally they have to install a JRE, install any optional packages like Java3D, set the path environment variable and then start a batch file. This doesn't exactly seem professional to the Windows end-user, who generally just expect to be able to hit an icon or an .exe file to run. This launcher addresses this problem by providing you with a small .exe file that launches your Java application in a foolproof way, while making sure that it looks exactly like any other Windows application.
The advantages of this launcher over the traditional way are many:
Users simply click an .exe file or shortcut to run the application.
No need for users manually to install a JRE or any extra libraries.
No need for users to set class path or path variables.
Users will never know you used Java.
No problems due to incompatible versions of Java already installed on the machine (mostly due to Microsoft's broken version) and this allows you to use non-standard JVM options such as setting heap size.
There are no problems with using the launcher with autorun, various installers (such as InstallShield) or various third party libraries.
It works with with any Java virtual machine no matter whether it are standard conforming or not. In fact it can be used to launch interpreters for languages such a Perl or Python, too.
If you provide your own native DLL libraries you are sure that your versions of the libraries are loaded - not some duplicates present in a system library.
This program is open-source and is public domain. Use it for what ever you want. However, if you edit the code and redistribute it again then please do not call it the Marner Java Launcher and please credit me for my work.
Download Marner Java Launcher 1.22 (40 kb). (released 2003-9-9) (includes both binary and source)
See the included readme.txt file for instructions. Enjoy!
It is very simple actually. The .exe provided loads a text file called launcher.cfg that tells it what program to start and with what parameters. It also allows you to set the directory of your Java root - this will be the current directory when Java starts. Then it starts the program you named and Java is running. Extremely simple but beautiful.
Should I bundle a Java VM with my application?
Bundling a JVM with your applications is highly recommended. The only drawback is that it will take up 20 MB extra disk space (but that is nothing these days) and the distribution will be 6 MB larger. Several other Java launcher available do not support bundling of JVMs and will sometimes fail.
If you do *not* bundle a JVM the following will happen:
How do I create a desktop icon for my application?
Doing so is best done from an installer program like InstallShield. During install such program will create a icon to the program .exe and will also provide an uninstall feature for you.
If you package your program with, say, WinZip (possibly self-extracting) then users will have to click the .exe file to start.
How do I change the icon embedded in the exe?
To do this you have two options:
1. Recompile the .exe. The source code and project files for Microsoft Visual C++ can be found in the source directory. In Visual C++ just replace the icon with your own one and then recompile. Doing this requires no C++ knowledge but requires Visual C++.
2. Use some program that does just this. One such program is the shareware program IconForge.
How do I make sure that the native DLLs I provide can be found?
In the case you use some third party library written for Windows (such as my own libraries JWindows or 6DX for Java) you must be sure that those DLL can be found by the system and that no other DLLs with the same name is used instead.
To be sure that your own native DLLs can be found you must place them in one of the following directories:
If you change the current directory during the execution of your program I recommend putting them in the JRE\bin directory.
Alternatively, if it is JNI based libraries you wrote yourself then you can place them wherever you want and the use System.load() instead of System.loadLibrary() to load them with an absolute path.
How do I change the name seen in the Windows Task manager?
If you start a Java application with this launcher and use say, javaw.exe then the Windows task manager will show that name. To change the name to your preferred one you need to change the name of javaw.exe. Take a copy of it into the same directory and then rename it to whatever you want. You should not just rename the old one without copying it first, since you then will be violating the license agreement with the JRE.
But I want to distribute my application as a stand-alone executable file. How do I do that?
Not with the Marner Java Launcher. You can use a static Java compiler instead. I recommend Excelsior Jet.
from another website
1. Make sure the SWT jar file is included in the Eclipse project build path
a. Download the standalone SWT jar file from eclipse.org even if you already have the ones that come with Eclipse. It is called swt.jar and you will package it with the executable JAR. Make sure it is the same version of SWT that you used to make your program.
b. In Eclipse, import swt.jar via Project Properties::Java Build Path::Libraries::Add External JARs. (Make sure to include the source .zip file). Also make sure to select the swt package in the Order and Export tab.
c. At this point, you should be able to compile and run your SWT application in the Eclipse SDK.
2. Do a standard Eclipse jar file export
a. Right click on the main .java project file and select Export.
b. Choose JAR File from the list.
c. Select the relevant packages and .classpath and .project resource files
d. Make sure Export generated class files and resources is selected and browse to the location where you want the JAR file to be created.
e. Specify Generate the manifest file and don’t seal the JAR or any packages. Choose the class containing the main method as the Main class .
3. Change the manifest file
a. Navigate to the JAR file you created and open it with WinZip.
b. Open the MANIFEST.MF file inside and copy the contents.
c. Create a new file called MANIFEST.MF and paste in the contents of the old manifest file.
d. Add the line Class-Path:
4. Replace the manifest file
a. Make sure the manifest file and the executable jar are in the same folder.
b. Open the command prompt and navigate to the containing folder.
c. Enter the command jar umf MANIFEST.MF
5. Package the JAR with SWT files
a. Put the updated executable JAR file, swt.jar, and the associate DLL in the same folder. The DLL can be pulled out of swt.jar and should have a name like swt-win32-####.dll on Windows.
b. The JAR file should now successfully execute. On Windows, you can usually just double click the JAR file in explorer and it will open. If that does not work, the command java –jar