• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

How IDE compiles a java file ?

 
Ranch Hand
Posts: 384
MyEclipse IDE Spring Java
  • 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 ??
 
Bartender
Posts: 6109
6
Android IntelliJ IDE Java
  • 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
MyEclipse IDE Spring Java
  • 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
  • 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.
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Likes 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
MyEclipse IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Jesper de Jong.




Regards
naveen
 
If I had asked people what they wanted, they would have said faster horses - Ford. Tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic