• Post Reply Bookmark Topic Watch Topic
  • New Topic

code to run a java class fiel in java program itself  RSS feed

 
muusa muzammil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello friends i m partially new to java .i would like to know tht suppose i have a class file stored somewhere on my machine n i want to run this class file using java program .then how could thiis be done
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
java ClassName? Read the Java Beginners FAQ

This topic should be in Beginning Java.
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to JavaRanch
 
muusa muzammil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey guys you didnt understood my question.
a:I have a main program in which i have to call another java class file execute n return the results ?
how could this be done
 
W. Joe Smith
Ranch Hand
Posts: 710
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would suggest looking up how to import classes. I think that is what you are looking for.
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if you want to do it dynamically, search for "reflection". Class.forName combined with Class.getMethod and Method.invoke can help you out.
 
muusa muzammil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
W. Joe Smith wrote:I would suggest looking up how to import classes. I think that is what you are looking for.

no i am not looking to import a class
Consider i have a dynamically changes java class tht is stored somewhere on my machine n i would like to call this class and run it using my main program
 
muusa muzammil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:And if you want to do it dynamically, search for "reflection". Class.forName combined with Class.getMethod and Method.invoke can help you out.

i would help me a lot if you could quote an example for this n yes i dont want to invoke any method from the class i would like to run the whole class
 
Rob Spoor
Sheriff
Posts: 21133
87
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http://java.sun.com/docs/books/tutorial/reflect/
 
muusa muzammil
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Prime wrote:http://java.sun.com/docs/books/tutorial/reflect/

hey thank you very much
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!