Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

can i compile java from java code?

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • 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
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • 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.
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • 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: 42967
73
  • Mark post as helpful
  • send pies
  • 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.
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • 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: 42967
73
  • Mark post as helpful
  • send pies
  • 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.
 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • 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 .
 
Bert Bates
author
Sheriff
Posts: 8898
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i'm going to slide this over to the intermediate forum...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic