Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Can we compile  RSS feed

 
Priyakant Charokar
Ranch Hand
Posts: 58
Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Suppose i have a class definition like this :

class CheckSyntax{
int var1=10;
}

this text data is available in stream.........

Can we compile the text through javac on a fly without saving the file.

More specific :
Suppose through a form post method somebody send me that text (class definition ) . So my Question is
Q1...can we compile that text as a normal class.
Q2...Further i want to catch hold of errors also. and show them as response.

Can anybody help me.

Priyakant Charokar
SCJP
SCWCD (....in progress)
 
Joe Ess
Bartender
Posts: 9428
12
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Priyakant Charokar:

Suppose through a form post method somebody send me that text (class definition ) . So my Question is
Q1...can we compile that text as a normal class.

Unlikely. Look at the javac documentation. It clearly states that the input must be a file. Of course, creating temporary files is a common and simple programming task.


Q2...Further i want to catch hold of errors also. and show them as response.

Look at the above link, the section called "PROGRAMMATIC INTERFACE"
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!