For Programmers: Free Programming Magazines  


Home > Archive > Java Help > May 2004 > running a java.class file









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author running a java.class file
don

2004-05-15, 8:31 pm

When I run a compiled java file from an MS DOS window I always have to type
java in front of the program....... how can I get around this..... I'm using
JBuilder9 to write and compile my source code..........


Roedy Green

2004-05-15, 9:31 pm

On Sat, 15 May 2004 19:21:54 -0400, "don" <don@panix.com> wrote or
quoted :

>When I run a compiled java file from an MS DOS window I always have to type
>java in front of the program....... how can I get around this..... I'm using
>JBuilder9 to write and compile my source code..........


see http://mindprod.com/jgloss/associations.html

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Tom

2004-05-17, 12:31 am

"don" <don@panix.com> wrote in message news:<c868mi$fh1$1@reader2.panix.com>...
> When I run a compiled java file from an MS DOS window I always have to type
> java in front of the program....... how can I get around this..... I'm using
> JBuilder9 to write and compile my source code..........


It doesn't really matter what editor that you are using. Java runs
the same way regardless of the editor used, or the platform that it
was created on.

Java does not run directly on any computer. When you type in java
SomeProgram, what you are doing is running a program called the Java
Virtual Machine, and telling it to run the program defined in
SomeProgram. Someone or something has to start the JVM.

One workaround, if you are writing programs with a GUI interface, is
to put the program in a Jar file. On Windows and Mac's, Jar files can
be run by clicking on the file, just like a native application
(assuming that Java is installed on the computer). If your program
does not have a GUI, then Jars won't help.
Stewart Gordon

2004-05-17, 10:32 am

Tom wrote:

<snip>
> One workaround, if you are writing programs with a GUI interface, is
> to put the program in a Jar file. On Windows and Mac's, Jar files can
> be run by clicking on the file, just like a native application
> (assuming that Java is installed on the computer). If your program
> does not have a GUI, then Jars won't help.


Wrong. You can change the association of .jar from javaw to java, just
as you can with any file type.

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Stewart Gordon

2004-05-17, 10:32 am

Roedy Green wrote:

> On Sat, 15 May 2004 19:21:54 -0400, "don" <don@panix.com> wrote or
> quoted :
>
>
> see http://mindprod.com/jgloss/associations.html


Does this mean that 1.4.2 or 1.5.0 has started accepting a filename in
place of a class name, or that Win2K/XP has a way around this limitation?

OP: If your system doesn't meet these criteria, see
http://groups.google.co.uk/groups?t...40212.67.96.135
for a launcher program to do the trick.

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Roedy Green

2004-05-17, 3:33 pm

On Mon, 17 May 2004 14:51:37 +0100, Stewart Gordon
<smjg_1998@yahoo.com> wrote or quoted :

>
>Does this mean that 1.4.2 or 1.5.0 has started accepting a filename in
>place of a class name, or that Win2K/XP has a way around this limitation?


no. You bundle your program in a jar and set up the association for
*.jar to java.exe

see http://mindprod.com/jgloss/jar.htm#EXECUTING

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Tom

2004-05-17, 6:32 pm

Stewart Gordon <smjg_1998@yahoo.com> wrote in message news:<c8af2h$m08$1@sun-cc204.lut.ac.uk>...
> Tom wrote:
>
> <snip>
>
> Wrong. You can change the association of .jar from javaw to java, just
> as you can with any file type.


Mea Culpa. I didn't think about that - probably because I've never
wanted to do that. My concern with this is that console programs are
often "beginner" programs that run very quickly and then end. I
wonder if the DOS window will stay open after the program finishes.
I don't know if the OP is a newbie or not, but eventually some newbie
will read this post. If the DOS window doesn't stay open, then any
newbie that tries this will get pretty frustrated.
Stewart Gordon

2004-05-19, 9:32 am

Roedy Green wrote:

<snip>
> no. You bundle your program in a jar and set up the association for
> *.jar to java.exe


That would add an extra step to the building of any app, which some
would consider overkill for one-class tests/samples.

And when developing, rejarring for every little change would defeat the
object of the exercise. OK, so whether there's any point here would
probably depend to some extent on the DE and project structure....

> see http://mindprod.com/jgloss/jar.htm#EXECUTING


404 at the mo.

Stewart.

--
My e-mail is valid but not my primary mailbox, aside from its being the
unfortunate victim of intensive mail-bombing at the moment. Please keep
replies on the 'group where everyone may benefit.
Roedy Green

2004-05-19, 2:32 pm

On Wed, 19 May 2004 13:49:35 +0100, Stewart Gordon
<smjg_1998@yahoo.com> wrote or quoted :

>
>404 at the mo.


try

http://mindprod.com/jgloss/jar.html#EXECUTING

or just look up "jar" in the index on nearly every page.

--
Canadian Mind Products, Roedy Green.
Coaching, problem solving, economical contract programming.
See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com