This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How IDE compiles a java file ?

 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wonder how an IDE like Eclipse compile and run a .java file ?

they (IDE) know about jdk installed in system.
they create a source file(.java) and save it on system.

How they compile .java into .class file ??
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some IDEs may come with their own compiler. Otherwise, when you install or configure the IDE, you point it to your JDK installation, and it invokes javac from there just like you would on the command line.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my point is that even after knowing the location of jdk installed directory , i cannot compile a file without using command line .I have to open command line and then invoke javac from there .

how can i do it without invoking command line , of course ,apart form using an IDE?



As i pass "javac Myclass.java" to command line .It seems unlikely that an IDE will open command line and then compile a file from there. ?


So how IDE do it ??.
 
Jeff Verdegan
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's certainly possible that the IDE is invoking javac via Runtime or ProcessBuilder. That would actually be my first guess.. On the other hand, I think for the last few versions, the JDK has included compiler classes, so maybe it's using those.
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
naveen yadav wrote:my point is that even after knowing the location of jdk installed directory , i cannot compile a file without using command line .I have to open command line and then invoke javac from there .

Yes, that's how it normally works when you compile a Java source file manually.

naveen yadav wrote:how can i do it without invoking command line , of course ,apart form using an IDE?

The Java compiler included in the JDK does not have a GUI. The only way to use it directly is from a command line prompt.

naveen yadav wrote:As i pass "javac Myclass.java" to command line .It seems unlikely that an IDE will open command line and then compile a file from there. ?

Eclipse has its own built-in Java compiler. It does not use the Java compiler in the JDK at all. Other IDEs call the Java compiler from the JDK and show its output in a custom console view. Just because you normally use a command prompt window to run the Java compiler, that doesn't mean that it is always necessary to have a command prompt window to run javac.exe. IDEs can just run javac.exe in the background and get the output from the compiler without you seeing any command prompt window.

Also, the Java compiler has an API so that it can be called from a Java program via the API. This API is in the package javax.tools.
 
naveen yadav
Ranch Hand
Posts: 384
Java MyEclipse IDE Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper de Jong.




Regards
naveen
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic