• 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
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

code to run a java class fiel in java program itself

 
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
 
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.
 
Marshal
Posts: 70215
281
  • 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
 
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.
 
Sheriff
Posts: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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: 21997
107
Eclipse IDE Spring VI Editor Chrome Java Ubuntu 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
 
rubbery bacon. rubbery tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic