Running Eclipse programs from outside Eclipse? [message #159694] |
Thu, 20 November 2003 14:44  |
Eclipse User |
|
|
|
Originally posted by: rhino1.NOSPAM.sympatico.ca
Can anyone give me guidance on how to run programs created within Eclipse
from the command line *without* Eclipse being launched?
One of my friends is quite interested in Java so I've been spending a couple
of hours with him each week trying to get him up to speed on how to write
Java. Unfortunately, his PC is very slow - Pentium 150! - and he has no
prospect of getting a newer one in the near future. He has a reasonable
amount of memory but it takes him many minutes to launch Eclipse each time.
In many cases, he simply wants to run his completed program from the command
line or via a batch file.
I've been able to help him run his programs the command line without
starting Eclipse when all of the code was in a single project. Here is an
example of one of the batch files I set up for him. It works fine:
set javapath=c:\j2sdk1.4.1_02\bin
set JarViewer=c:\Program Files\eclipse\workspace\Jar Viewer\bin
cd %JarViewer%
%javapath%\java.exe -classpath "." jarviewer.JarViewer
However, I am having problems when the program he is trying to run has
dependencies in another project. For example, if his program is in a project
called Jars and has dependencies on another project, like Common, which
contains a package called common that contains a class called JarFileFilter,
the above batch file generates this:
Exception in thread "main" java.lang.NoClassDefFoundError:
common/JarFileFilter
How do I need to change the batch file to make the classes of the Common
project visible? Would the .project or .classpath files in Eclipse be of any
use? I have no trouble running the program within Eclipse.
Rhino
---
rhino1 AT sympatico DOT ca
"If you want the best seat in the house, you'll have to move the cat."
|
|
|
Re: Running Eclipse programs from outside Eclipse? [message #159852 is a reply to message #159694] |
Thu, 20 November 2003 21:01   |
Eclipse User |
|
|
|
Originally posted by: manahan.NOSPAM.ca.ibm.com
A place to start (online anyway) is
http://java.sun.com/docs/books/tutorial/
Go through the topics there are threads about basic application,applets,
jars etc. And how to use them. The "SDK Tool Documentation"
documentation in the JDK docs describe how classes are found and how to
set the classpath etc.
Addtionally the Docs for the JDK you are using have links to Demo,
Tutorials which you may find useful.
http://java.sun.com/j2se/1.4.1/docs/index.html for the 1.4.1 JDK for example
Hope this helps,
Peter
Rhino wrote:
> Can anyone give me guidance on how to run programs created within Eclipse
> from the command line *without* Eclipse being launched?
>
> One of my friends is quite interested in Java so I've been spending a couple
> of hours with him each week trying to get him up to speed on how to write
> Java. Unfortunately, his PC is very slow - Pentium 150! - and he has no
> prospect of getting a newer one in the near future. He has a reasonable
> amount of memory but it takes him many minutes to launch Eclipse each time.
> In many cases, he simply wants to run his completed program from the command
> line or via a batch file.
>
> I've been able to help him run his programs the command line without
> starting Eclipse when all of the code was in a single project. Here is an
> example of one of the batch files I set up for him. It works fine:
> set javapath=c:\j2sdk1.4.1_02\bin
> set JarViewer=c:\Program Files\eclipse\workspace\Jar Viewer\bin
> cd %JarViewer%
> %javapath%\java.exe -classpath "." jarviewer.JarViewer
>
> However, I am having problems when the program he is trying to run has
> dependencies in another project. For example, if his program is in a project
> called Jars and has dependencies on another project, like Common, which
> contains a package called common that contains a class called JarFileFilter,
> the above batch file generates this:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> common/JarFileFilter
>
> How do I need to change the batch file to make the classes of the Common
> project visible? Would the .project or .classpath files in Eclipse be of any
> use? I have no trouble running the program within Eclipse.
>
>
> Rhino
> ---
> rhino1 AT sympatico DOT ca
> "If you want the best seat in the house, you'll have to move the cat."
>
>
|
|
|
Re: Running Eclipse programs from outside Eclipse? [message #159869 is a reply to message #159694] |
Thu, 20 November 2003 21:59   |
Eclipse User |
|
|
|
Originally posted by: jrubio.airphoria.com
There are two ways you can do this.
One is to export the project to a jar file and then add that dependency to
the classpath, or add the bin directory to the classpath.
So in summary, if you have a project A (JarViewer) that depends on B
(Common) you would have a folder in eclipse that would be c:\Program
Files\eclipse\workspace\B\bin that contains the class files, so you can run
something like this (assumming you run this command from project A that
lives in c:\Program Files\workspace\A\bin):
java -classpath .;../../Common/bin JarViewer.jarViewer
If you export the Common project to a jar file, just add it to the
classpath.
java -classpath .;Common.jar JarViewer.jarViewer
Hope it helps.
Jose
"Rhino" <rhino1@NOSPAM.sympatico.ca> wrote in message
news:bpj5fi$unr$1@eclipse.org...
> Can anyone give me guidance on how to run programs created within Eclipse
> from the command line *without* Eclipse being launched?
>
> One of my friends is quite interested in Java so I've been spending a
couple
> of hours with him each week trying to get him up to speed on how to write
> Java. Unfortunately, his PC is very slow - Pentium 150! - and he has no
> prospect of getting a newer one in the near future. He has a reasonable
> amount of memory but it takes him many minutes to launch Eclipse each
time.
> In many cases, he simply wants to run his completed program from the
command
> line or via a batch file.
>
> I've been able to help him run his programs the command line without
> starting Eclipse when all of the code was in a single project. Here is an
> example of one of the batch files I set up for him. It works fine:
> set javapath=c:\j2sdk1.4.1_02\bin
> set JarViewer=c:\Program Files\eclipse\workspace\Jar Viewer\bin
> cd %JarViewer%
> %javapath%\java.exe -classpath "." jarviewer.JarViewer
>
> However, I am having problems when the program he is trying to run has
> dependencies in another project. For example, if his program is in a
project
> called Jars and has dependencies on another project, like Common, which
> contains a package called common that contains a class called
JarFileFilter,
> the above batch file generates this:
> Exception in thread "main" java.lang.NoClassDefFoundError:
> common/JarFileFilter
>
> How do I need to change the batch file to make the classes of the Common
> project visible? Would the .project or .classpath files in Eclipse be of
any
> use? I have no trouble running the program within Eclipse.
>
>
> Rhino
> ---
> rhino1 AT sympatico DOT ca
> "If you want the best seat in the house, you'll have to move the cat."
>
>
|
|
|
Re: Running Eclipse programs from outside Eclipse? [message #160169 is a reply to message #159694] |
Fri, 21 November 2003 11:46  |
Eclipse User |
|
|
|
Originally posted by: thomas_maeder.ch.ibm.com
Here's what I would do:
1) Run the program from within eclipse
2) Select the VM process in the debug perspective
3) Select properties from the conext menu
4) copy the command line from the resulting dialog.
5) Paste it into your batch file, change any paths that are different on
your friends machine.
6) run.
Thomas
Rhino wrote:
> Can anyone give me guidance on how to run programs created within Eclipse
> from the command line *without* Eclipse being launched?
>
|
|
|
Powered by
FUDForum. Page generated in 0.05668 seconds