• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Jeanne Boyarsky
  • Tim Cooke
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
Bartenders:

Execute without compiling

 
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to develop a java program which takes another java program as input and executes the input java program.Can anyone please suggest me how to do it?Thanks.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amod Gupta wrote:I want to develop a java program which takes another java program as input and executes the input java program.Can anyone please suggest me how to do it?Thanks.




It looks like you want to develop another JVM in Java why do you want to do that? what do you want to?
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no i dont want to develop a jvm what i want to do is take a java program as input compile the input program and execute it from my main program only.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Check out the javax.tools.JavaCompiler
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks
 
Bhagat Singh Rawat
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amod Gupta wrote:no i dont want to develop a jvm what i want to do is take a java program as input compile the input program and execute it from my main program only.




You want to do something like

Or you want to take java code as input and compile that code in side of the Main class??
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Bhagat Singh Rawat wrote:
Or you want to take java code as input and compile that code in side of the Main class??


doesnt matter say i have the class in a string variable.
 
Bhagat Singh Rawat
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amod Gupta wrote:doesnt matter say i have the class in a string variable.



Go through the link below, may be it will help you!!!

Compile a Java source from inside a Java program
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Bhagat Singh Rawat
Thanks a lot
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What Bhagat Singh Rawat proposed won't help you, that code shows you how to dynamically load a class - but the class will have to be compiled beforehand.
 
Ranch Hand
Posts: 419
Mac jQuery Objective C
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This link Generating classes should help you. Go throught the article really useful.
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now I want to save the input program.Can i save it in a database such as ms access?If yes then how.
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By "input program", do you mean the source code? If so, that's just a string, so any character field should do. If you mean the class file, then you need a BLOB field. Search the JDBC forum (and the Sun Java Tutorial) for how to use either of those.
 
Amod Gupta
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ulf Dittmer wrote:By "input program", do you mean the source code? If so, that's just a string, so any character field should do. If you mean the class file, then you need a BLOB field. Search the JDBC forum (and the Sun Java Tutorial) for how to use either of those.



So there is no size limit to string field?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That depends on your DB, but VARCHAR fields can often be made as large as 2^31 bytes, which is sufficient for Java source files.
 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
look at this beanshell. This may help you to get some idea or use it.
 
I'm not dead! I feel happy! I'd like to go for a walk! I'll even read a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic