• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Compiling Java for use in Windows...

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,

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 ]
 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
cant you do it as a batch file in windows?
 
Preetham Chandrasekhar
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and later change the batch icon to your corporate icon
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
and you don't need to recompile the java-files.
Ever heard of crossplattform.

And for compilation you don't need a cygwin - you may get a jdk for windows.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Stefan Wagner:

And for compilation you don't need a cygwin - you may get a jdk for windows.



You do need Cygwin if you want to use a command prompt under Windows without losing your mind entirely.
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no you don't. You just need to know how to use the Windows command prompt...
 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Ranch Hand
Posts: 385
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You used -m with JAR and you didn't specify manifest file...

I humbly suggest reading Trail: JAR files
 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
D'oh!

Yep, caught that a few minutes ago....

Thanks for the link, I'll do some exploring.
 
Joe Vahabzadeh
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, I think I must be doing something wrong.

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

How do I solve this problem?


Thanks again in advance.
 
Stefan Wagner
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Ranch Hand
Posts: 3061
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.

HTH

Layne
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic