File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes using command to run swing application ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "using command to run swing application ?" Watch "using command to run swing application ?" New topic
Author

using command to run swing application ?

Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 437
hi, good day , i have done some swing application , but i forgot how to run the class file ?

say my folder in c:\classes\my\um

and my application mainClass is c:\classes\my\um
\StartApplication.class

when i want to run the start.class , what command i should use ?

i have try


it doesn't work and prompt me error "Exception in thread "main" java.lang.NoClassDefFoundError: StartApplication (wro
ng name: my/um/StartApplication)"


thank you for guidance
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 39547
    
  27
Try this:

java -classpath c:\classes my.um.StartApplication


Ping & DNS - updated with new look and Ping home screen widget
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 437
i get this error with your try

Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

You need to add the Apache Commons logging Jar file -- along with the Jar files for any other libraries you used -- to the class path as well.

Moving to Java in General (Beginner) for any followup.


[Jess in Action][AskingGoodQuestions]
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 437
it still give me error when i type as below :



what else i miss ?
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

You don't put directories in which jar files appear onto the class path; you put the jar files themselves in. Furthermore, multiple entries are separated by a semicolon, not a comma.

java -classpath c:\classes;c:\classes\lib\commons-logging.jar;c:\wherever\whatever.jar Foo.java
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 437
if i have many third party jar file like commons-logging.jar and so on, is it the only way to add one by one in java -classpath ?

anyway to set all sum of jar file in once ?

thank you
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24166
    
  30

You have to add them one at a time. Normally people write a batch file or shell script to contain the command to start a program.
Nakata kokuyo
Ranch Hand

Joined: Apr 13, 2005
Posts: 437
thanks, Ernest Friedman-Hill for guiding
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: using command to run swing application ?
 
Similar Threads
problem running .BAT file from the Java app
Class Path
running with command line
How to execute .BAT thru java Application
Unable to parse setupCmdLine: null\bin\setupCmdLine.bat