Win a copy of Testing JavaScript Applications this week in the HTML Pages with CSS and JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

running with command line

 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,

i know this sounds really newbie. but how do i run my swing application on a command line?
 
Ranch Hand
Posts: 494
Eclipse IDE Postgres Database Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What kind of OS that do you use?

firstly, you have to set path all of the libraries that you need..
 
Marshal
Posts: 69869
278
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java MySwingClassWithMainMethod "Frame Title"
 
Bartender
Posts: 11445
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From the command line you can run it like
java MyMainClass where MyMainClass is the one with the main method.

If you got a self executing jar file (where the manifest file includes the Main class entry) you can run it like
java -jar MySwingApp.jar
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i got this :



what is wrong ? is it because of the library? how do i add the library specifically?

 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You run .class files, not .java files and you don't need the extension
Try
java Noose_Machine
 
bryan lim
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i see... that's very noob of me. really sorry about it.

i have another question. i have around seven external libraries which means i have to add in a long list of jar into the command line..

is there a solution to that? like combining them all into a single jar? how do i do that?
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're using Java 1.5 or later you can put all the jars into a directory and then use a wild card in your classpath
java -cp <path to myjardirectory>\* Noose_Machine

Note that the wild card is * and not *.jar

Alternatively, when you start writing more complex applications, you can combine all your class files into a jar file and then specify a list of all the required jars in the manifest file for your jar file. You then run your program with the java -jar command. There are plenty examples of this on these forums
 
Forget this weirdo. You guys wanna see something really neat? I just have to take off my shoe .... (hint: it's a tiny ad)
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic