Running program independent of Compiler
Hi,
I just finished a large java program and want to run it on other people's windows machines independently of the compiler I'm using. Can someone tell me (or tell me a tutorial that tells me) how to do this. I think it involves batch files, but I've no experience with them.
Until now I've just used the "build & run" option from my Netbeans compiler.
Any takers?
[399 byte] By [
LemonLiona] at [2007-11-26 23:00:23]

> I've tried everything in the tutorial on running
> programs from the command line. I can't get anything
> working from a batch file or direct from command
> line. I get an error (Exception in thread "main"
> java.lang.NoClassDefFoundError: Client) and the
> tutorial says you might be able to fix be using "set
> CLASSPATH=" but that didn't help.
>
> I don't see how jar files will help me, all they are
> are collection files. What I need is a way of
> running a java program independent of a compiler. I
> tried making a jar file using the jar command that
> they said in the jar tutorial but that didn't work
> either (maybe they meant it for unix?)
>
> Anyway, still got the same problem...
you can't have followed the tutorial properly, then. it definately works. this is just another example of why IDEs are a bad idea for inexperienced coders. it shields them from too many important problems such as this. using the CLASSPATH environment variable isn't a particularly good idea, either. and no, jars are not unix-specific
what exactly is it you're doing? I mean, what are you doing to run your code that isn't working?
I'm running windows command prompt. I'm going to the directory which my *.class files are in. I'm checking that they're are in there with dir function. They are there. I am inputing "java Client". I receive an error. Here is what I'm getting:
C:\Documents and Settings\Jim Heart\Collab\build>cd classes
C:\Documents and Settings\Jim Heart\Collab\build\classes>dir
Volume in drive C is Partition_1
Volume Serial Number is EC74-E3ED
Directory of C:\Documents and Settings\Jim Heart\Collab\build\classes
27/03/2007 06:12<DIR> .
27/03/2007 06:12<DIR> ..
27/03/2007 07:02 6,281 Client.class
27/03/2007 04:34663 Client.class.jsmooth
27/03/2007 05:54 1,363 ClientThread.class
27/03/2007 06:26705 CollabFrame$1.class
27/03/2007 06:26707 CollabFrame$10.class
27/03/2007 06:26708 CollabFrame$11.class
27/03/2007 06:26708 CollabFrame$12.class
27/03/2007 06:26705 CollabFrame$2.class
27/03/2007 06:26705 CollabFrame$3.class
27/03/2007 06:26705 CollabFrame$4.class
27/03/2007 06:26705 CollabFrame$5.class
27/03/2007 06:26705 CollabFrame$6.class
27/03/2007 06:26705 CollabFrame$7.class
27/03/2007 06:26705 CollabFrame$8.class
27/03/2007 06:26705 CollabFrame$9.class
27/03/2007 06:2616,921 CollabFrame.class
23/03/2007 01:25747 CollConnectDialog$1.class
23/03/2007 01:25747 CollConnectDialog$2.class
23/03/2007 01:25 4,302 CollConnectDialog.class
27/03/2007 07:02733 CollServerFrame$1.class
27/03/2007 07:02733 CollServerFrame$2.class
27/03/2007 07:02733 CollServerFrame$3.class
27/03/2007 07:02 6,502 CollServerFrame.class
27/03/2007 05:54 1,438 DocUpdater.class
27/03/2007 01:34677 JDialog$1.class
27/03/2007 01:34566 JDialog$2.class
27/03/2007 01:34 2,837 JDialog.class
27/03/2007 03:4123 run.bat
27/03/2007 07:02 2,877 Server.class
27/03/2007 07:02 5,861 ServerThread.class
23/03/2007 01:29 1,141 ServerThreadList.class
31 File(s) 63,613 bytes
2 Dir(s) 15,247,794,176 bytes free
C:\Documents and Settings\Jim Heart\Collab\build\classes>java Client
Exception in thread "main" java.lang.NoClassDefFoundError: org/jdesktop/layout/G
roupLayout$Group
at Client.<init>(Client.java:45)
at Client.main(Client.java:344)
C:\Documents and Settings\Jim Heart\Collab\build\classes>
--
And in response to georgmc, I did follow the tutorial as it said. If you think I didn't, please point out where. And I wasn't suggesting that Jar's are unix specific, merely that the ways of producing them in the tutorial supplied might have been. My end goal is to produce a file which can be double clicked on by an ordinary user, which will run my java program. However, presumably before I get to that stage, I need to be successful in getting it to run from the command line directly. I have not been able to achieve that and I have no idea why. (My program runs fine in Netbeans)
Hope one of you can help, I remember in 2nd year university we had a similar problem getting windows machines to do this, including the lecturer, which probably explains why I'm having so much trouble...
LemonLion