• 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
  • Tim Cooke
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
Saloon Keepers:
  • Piet Souris
Bartenders:

can i compile java from java code?

 
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello all
can i compile java source from java code?
the reason i asking is :
i have some test files that representing classes and methods and i need to transform them into java code ( i know to do the lexing ) and then this code compile and store some how the class's in memory . can it be done in java 1.5 ?
not 1.6 .
thanks
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, this can be done. The JavaIntermediateFaq points to two different ways, in a paragraph about expression evaluation, towards the end of the page.
 
ben josh
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello
well this is cool way to comiple java , but i meant more like
compiling the java source and manege all the classes/object created
in memory and not like "real *.class" files.
thanks
 
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
If you want to do everything in memory, you can use the Javassist library, which is also linked on that page.
 
ben josh
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi thanks for the replay , as i see it still reads class files
that compiled in some form . i need to do every thing in memory .
to transform file (idl ) to java source and compile it then store the
classes in memory .
 
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
No, Javassist does not read existing class files. It can do that, but it's not necessary. I've used it to create classes in memory from scratch, with no reference to any existing class.

But now that you mention IDL files, it seems that you are actually trying to do something very different. In order for us to help you, we'd need to know more about what exactly that is.
 
ben josh
Ranch Hand
Posts: 620
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
what i need to do is :
compile idls -> use the java source generated -> compile to classes
and all this in memory .
 
author
Posts: 9050
21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i'm going to slide this over to the intermediate forum...
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic