Stop Microsoft

Miscellaneous => Programming & Networking => Topic started by: Xeen on 15 October 2003, 03:19

Title: Java question
Post by: Xeen on 15 October 2003, 03:19
If I write a program consisting of several classes all in java, is there any way for me to convert it to Windows exe and/or dll files? I ask because I'm writing a program but do not want to have it launch in Windows by having to type the command java classname in command line. I want to be able to create an executable file for it. Any ideas?
Title: Java question
Post by: flap on 15 October 2003, 03:42
Create a .bat file.
Title: Java question
Post by: Stryker on 15 October 2003, 04:02
or a shortcut
Title: Java question
Post by: Xeen on 15 October 2003, 04:10
perhaps I should explain my problem in more detail. My java program is NOT command line. It has a GUI. So if I create a batch file or shortcut to the file then Windows will still open the command prompt window which will stay there until the java GUI is closed. Is there any way to get around this problem? I want my program to run like any other program, without any command line windows behind it.
I know this problem wouldnt exist if I were writing in C++ but I don't know c++, but know java very well.
Title: Java question
Post by: flap on 15 October 2003, 04:14
No, that isn't possible.
Title: Java question
Post by: Xeen on 15 October 2003, 04:15
quote:
Originally posted by flap:
No, that isn't possible.


Crap   :confused:
Title: Java question
Post by: flap on 15 October 2003, 04:21
Blame Microsoft. It's because of Windows' utterly rudimentary support for terminal applications. Under Unix you could run it in the background from a terminal window, or run it attached to a non-tty so you wouldn't have to have a term window open at all. No such option in braindead windows.

[ October 14, 2003: Message edited by: flap ]

Title: Java question
Post by: Stryker on 15 October 2003, 04:26
can you modify your java program to use some of of the windows' api calls and find the dos windows that opens up and hide it? It'll be a little bit of extra work, and i'm not sure if java is capable of such things.
Title: Java question
Post by: SAJChurchey on 15 October 2003, 21:34
There has to be a way to execute Java programs w/out that window.  Because there are applications written by Sun in Java that runs in Windows just fine w/out a terminal window.  I never programmed java on a Windows platform.  Can you tell me more about batch files and such?
Title: Java question
Post by: jasonlane on 15 October 2003, 21:44
You may want to look into JINI / Java Web Start, it may not be what your looking for. Hope it helps though   ;)  

Web Start (http://java.sun.com/products/javawebstart/)
Title: Java question
Post by: flap on 15 October 2003, 21:53
quote:
Because there are applications written by Sun in Java that runs in Windows


I'm assuming they use some kind of native windows exe as a wrapper.
Title: Java question
Post by: fmrmicroserfunemployed on 17 October 2003, 02:47
Dude,

  You can compile to exe with Java. gcc, gck.
 
  You can probably use "start" or "call" DOS command line shell commands with some options to hide that nasty DOS window in the background.

   You can write a really quick C++ or VB to use Exec   /exec (C/vb) or CreateProcess to fire it up with whatever windows show/hide, min/max you want.

Cheers!  :eek:
Title: Java question
Post by: Xeen on 17 October 2003, 03:00
quote:
Originally posted by HadJobBeforeMSFTnIndia:
Dude,

  You can compile to exe with Java. gcc, gck.
 
  You can probably use "start" or "call" DOS command line shell commands with some options to hide that nasty DOS window in the background.

   You can write a really quick C++ or VB to use Exec   /exec (C/vb) or CreateProcess to fire it up with whatever windows show/hide, min/max you want.

Cheers!   :eek:  



Can you explain in more detail?
Title: Java question
Post by: xyle_one on 30 October 2003, 04:23
itm
Title: Java question
Post by: badkarma on 30 October 2003, 21:35
The mentioned methods have a few drawbacks:

 
quote:
You can probably use "start" or "call" DOS command line shell commands with some options to hide that nasty DOS window in the background.



Using javaw instead of java to launch your java program solves this, but the windows task list (or *nix process list) will still show the nondescriptive javaw.exe as the running process, which isn't very nice.

 
quote:

 You can write a really quick C++ or VB to use Exec /exec (C/vb) or CreateProcess to fire it up with whatever windows show/hide, min/max you want.



I'm not very familiar with the windows API (read: not at all) but I think exec and createprocess will spawn new processes and generate additional entries in your task list (ofcourse I could be entirely wrong here  (http://smile.gif) )

However, there is another option (the one I chose when I was messing around with this) which is to use JNI (java native interface) to spawn a java vm and pass your class files to it. However, you will still need a jre installed for the program to run and sun's binary license prevents you from just including the needed files and not the whole JRE. (I might have the code I wrote lying around, it's ugly but it works)

If you want a "native" executable (ie. no VM required) you're out of luck (unless you're willing to spend at least a few hundred dollars) because gcj's (gcc for java) AWT implementation is shoddy at best with lots of unsupported stuff.