Skip to main content
gamedev.net
🔒 Locked

java questions

Started by CProgrammer 7 replies 350+ views
Original Post
CProgrammer
CProgrammer
1.)Can I have a java window without the console screen. Like in a Win32 app in C++. 2.)Im using JCreatorV3 as a compiler. How can I create a real executable file with java, not just class files. -CProgrammer
trivierph
trivierph
1) You will have to design a application that uses Java GUI API, etiher AWT (fast, but old and rather ugly), Swing (quite neat, but sometimes very slow) or SWT (way faster, but a bit trickier to use - and not part of a standard JDK). See Swing tutorials on sun's site for more detail about the first two, and eclipse.org for info about SWT.

What you will have is a main class (the one that contains the main method) creating an object that subclasses the JFrame object (the equivalent of a Window object, I guess), call its show() method, and that's all. Events are managed by some part of the API (basically listeners), you only have to declare the bahavior to handle thoses events.

2) A Java compiler, as far as I know, is only meant to turn Java code (.java files) into Java Virtual Machine bytecode (.class files). I suppose it must be possible to convert java bytecode into an executable for one particular system & machine , but that is just not the idea of using Java, is it ?!!! What you want is to have your java program executable "anywhere", which is why you rely on a Virtual Machine to execute the byte-code.
You *have* to create class files, and this is those files that your JVM (the java program) will execute. And if you want a single executable, well you can always create a batch file containing only
 java MyProgamMainClass   
..

Good luck
pH

[edited by - trivierph on April 19, 2004 10:22:28 AM]
CProgrammer
CProgrammer
Thanks for the replies.
Im aware of the fact that java is platform independent thanks to the virtual machine. However I need my app to be user friendly to those who dont know much about computers.
So the batch file idea is a posibility thanks. However, am I allowed to reditribute the necessary java files?
Oh and using JFrame doesnt get read of the console at startup. Any posibility there?

Spudder
Spudder
If your going the GUI route then to get input from the user you can use the showInputPrompt method of JOptionPane class, then you can use Integer.parseInt() or its equilavents to retrieve non-string data from the user.
Koroljov
Koroljov
To get rid of the console, you have to put it in a jar file (like Anonymous Poster said), and execute it by double-clicking on the jar file.

Using a GUI interface will not hide the console.
Why do my programs never work on other computers?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.