Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / Tools / January 2006

Tip: Looking for answers? Try searching our database.

java command-line main() file execution

Thread view: 
bb - 10 Jan 2006 22:51 GMT
I have a class file with a main method in the following directory:
C:\tea\emat\web\WEB-INF\classes\emat\com\edi
The name of the file is: Edi210Parser. The class has a main method.
I've developed and tested the file under Eclipse, which has shielded me
from the classpath and command-line args.

I've defined the file in the Windows classpath setting as:
C:\tea\emat\web\WEB-INF\classes\emat\com\edi;

For the life of me I can't remember how to run the file from a Windows
command-line. I've tried the following:
c:>java -classpath emat\com\edi\Edi210Parser out.txt (to read the input
file that exists in the same directory)

I've changed directories to the place where the file is:
C:\tea\emat\web\WEB-INF\classes\emat\com\edi and run:
c:\tea\emat\web\WEB-INF\classes\emat\com\edi>java Edi210Parser out.txt
and
c:\tea\emat\web\WEB-INF\classes\emat\com\edi>java
emat.com.edi.Edi210Parser out.txt

The closest I've come to getting it right is:
c:\tea\emat\web\WEB-INF\classes\emat\com\edi>java -classpath
EdiParser210 out.txt
which results in:
Exception in thread "main" java.lang.NoClassDefFoundError: out/txt,
which makes no sense at this point but shows (or seems to) that the
class was found.

Any help would be appreciated....
Roedy Green - 10 Jan 2006 23:23 GMT
>For the life of me I can't remember how to run the file from a Windows
>command-line. I've tried the following:
>c:>java -classpath emat\com\edi\Edi210Parser out.txt (to read the input
>file that exists in the same directory)

see http://mindprod.com/jgloss/javaexe.html
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.

Greger - 14 Jan 2006 11:06 GMT
> I have a class file with a main method in the following directory:
> C:\tea\emat\web\WEB-INF\classes\emat\com\edi
[quoted text clipped - 26 lines]
>
> Any help would be appreciated....

what package is your class in?

Signature

www.gregerhaga.net

Ian Shef - 16 Jan 2006 19:39 GMT
Greger <boss@gregerhaga.net> wrote in news:dqals3$36p$1@phys-
news4.kolumbus.fi:

>> I have a class file with a main method in the following directory:
>> C:\tea\emat\web\WEB-INF\classes\emat\com\edi
[quoted text clipped - 28 lines]
>
> what package is your class in?

You told Java wheere to find your class ( -classpath ...).
You didn't specify what class to use, so out.txt was used.  This means
class txt in package out, which should be located at out\txt (which Java
will report as out/txt).  This, of course, was wrong, and thus the
Exception.

Please specify the class that contains your main method.
Do NOT suffix the name with ".class" !

Signature

Ian Shef     805/F6      *    These are my personal opinions    
Raytheon Company         *    and not those of my employer.
PO Box 11337             *
Tucson, AZ 85734-1337    *



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.