• 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
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

Calling other Java files???  RSS feed

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I want to call a Java application i have created from within the code of another Java application. Both of the class files will be in the same folder! Is this possible? If so, how?

Thanks for any help,

Emile
 
Bartender
Posts: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is quite possible.

[CODE]
//Class1.java
public class Class1{
public static void main(String argv[]){
// Do some Stuff.
Class2.main(someStringArray);
}
}

//Class2.java
public class Class2{
public static void main(String argv[]){
// Do some Other stuff.
}
}
 
author and iconoclast
Posts: 24203
40
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Absolutely possible -- just do it! I can't tell you exactly what to do, not having seen the code, but one class can create instances of another class and call its methods, or call the static methods of that class directly, just as you create objects of API classes and call their methods. You can even call "main":

  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!