Ok, I'm stubborn, I used to work in UNIX. Back then I wrote my code in 'vi', compiled with 'javac', and ran my programs with 'java'
Now I'm working on a Windows XP machine. So what do I do? I get the cygwin suite so I can have a unix-like shell, I use 'vim' for Windows, and I still compile using 'javac' and run the program using 'java' from the command line.
Only now I have to compile this thing with a nice friendly corporate icon so that the user can simply double-click and have the program do its thing. Except I haven't the slightest idea how to do this.
So, how do I accomplish this? I need to compile, and have an icon the user can double-click on to run the program without doing anything command-line. [ January 27, 2005: Message edited by: Joe Vahabzadeh ]
Well, I use cygwin only because I like having some of the Unix tools. I don't care much for the DOS commands, and in XP, it seems like they took some things out (DOSKey for example doesn't seem to exist anymore!)
But I didn't know if I had to do something different when compiling if I wanted to get a single, clickable icon to run it.
I was thinking of going the batch file route. But it seems, I don't know, a little sloppy somehow. If I go the batch file route, is there any way to prevent the DOS window from popping up?
I came across a reference to making .jar files, and that I should be able to accomplish what I want with those. Unfortunately, I get an error when I attempt the following:
DST is the main class that gets executed, and has the main method.
>jar cvfm DST.jar *.class
java.io.IOException: invalid header field at java.util.jar.Attributes.read(Attributes.java:383) at java.util.jar.Manifest.read(Manifest.java:167) at java.util.jar.Manifest.<init>(Manifest.java:52) at sun.tools.jar.Main.run(Main.java:124) at sun.toools.jar.Main.main(Main.java:904)
Clearly I've done something wrong, but I can't figure out what.
And finally, the DST class does make a call to a .dll that was written in C++ (needed something OS-specific that can't be done in Java). I don't know if that will throw things off.
I've been able to get the .jar file created, and I have a manifest file that looks as follows:
I have a directory C:\Projects\java and that's where all the classes I use are, including DST. Then there are Microsoft JDBC classes which all exist under the C:\Projects\java\com directory.
So, from the command line I type:
jar cvfm DST.jar DST.manifest *.java *.dll com (the *.dll is because there's a file called admincheck.dll that DST makes a call to)
My classpath has the following in it: C:\Projects\java C:\Projects\java\DST.jar
However, I get the error "Could not find the main class. Program will exit." if I use javaw DST.jar.
On the other hand, using java -jar DST.jar or double-clicking on the icon for DST.jar works. I don't understand why they work and javaw doesn't from the command line.
Can anyone help me with that?
Separate problem: If I copy the DST.jar file to another directory, and I add that directory to the classpath (and the directory\DST.jar as well), then double-clicking and javaw both fail. java -jar on the other hand gives me an error that admincheck is not in java.library.path
a) b) Specify the classpath (especially: to the ms-jdbc-stuff) in the Manifest. (To external jars and directories, containing classes.)
c) Not sure about the dll, but I guess it's useless in the jar. It needs to be in /Winhome/system32 (only a guess).
d) Windows without cygwin is possible. Google for UnxUtil(s). A bash-like shell, sed, awk, tail, head, false, sort, less, ... Most of the things, a normal man needs. Of course, the real linuxfeelin' is missing... [ February 03, 2005: Message edited by: Stefan Wagner ]
As a disclaimer, I didn't read through all the details about your current problems. However, from your original question (and some of the more recent comments), it looks like you should create an executable jar. In fact, it looks like you are having trouble doing just that. May I suggest using the Search tool to search this and the Java In General (beginner) forum for previous discussion on this topic. Perhaps someone has encountered similar difficulties in the past. You should also be able to find information by googling for "executable jar" or something similar.