Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Calling other Java files???  RSS feed

 
Emile Ghazzawi
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
 
Joel McNary
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.
}
}
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
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!