To run a class you don't need to launch the java executable.
Create a classloader and use that to fork off the class in-process :)
You can also do that to compile classes. Simply hook into Ant which is a Java application and can compile Java classes for you (by hooking into the JDK).
Examining the Ant source should be interesting (I've not yet done so) to see how they do it in a platform independent way.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
confusing? It's what I'd do. It's platform independent which is important as I work on several operating systems at the same time (Windows, 2 versions of Linux, and AIX, and I hope to add a Mac sometime next year).
And calling Ant should be rather easy. probably easier in fact than capturing the commandline output.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Ant is a tool similar to make (which is for C/C++ mainly).
It's written completely in Java so can easily integrate with Java applications.
There's books written about it, I'm barely scratching the surface by using it from the commandline to compile and package my projects.
Maybe next year when I may have time to do more I'm going to really dive into it :)
http://ant.apache.org
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
JeffHeaton
Junior Poster in Training
58 posts since Jul 2005
Reputation Points: 12
Solved Threads: 0
The trick is building the xml file to have ant do tricks like run unit tests, deploy your application to a J2EE server, and things like that :)
And of course integrating Ant inside another application is a bit more involved than just calling the command from the prompt.
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Hi everyone,
jwenting is right. Plug in ant as its more useful and easier and to build an ide is not an easy task. But if you want to still pursue it read up about pipe streams in java. You will also have to use window listeners and not set a default closing for the JFrame.
Richard West
freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10
Of course what he's doing/planning isn't really to make a compiler but to call an external compiler :)
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
jwenting
duckman
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
Hi everyone,
Is it possible to create a Java compiler? Could you
make a Notepad-like application, save the code as
a .java file, compile it into a .class file, and run it?
It seems you want to create an ide and not a comppiler but the answer is that its possibleBasically, I want to combine Notepad and Command Prompt.
Duly notedI think u have that Code. Please send that full coding please
I doubt he or anyone including myself will send the code.
What you can do is create a topic on creatig an ide by yourself and i'm sure the others will walk you through it if you have specific questions
Here are some tips for you
Runtime
JTextArea
Pipe And Streams
Richard West
freesoft_2000
Practically a Master Poster
623 posts since Jun 2004
Reputation Points: 25
Solved Threads: 10