Click here to Skip to main content
16,015,629 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
if it is possible to compile the .java file using c#.net.
Posted

Sample Code is:

System.IO.StreamWriter file = new System.IO.StreamWriter(filename );
file.WriteLine(textBox1.Text);
file.Close();

System.Diagnostics.Process.Start ("Javac",filename );
 
Share this answer
 
First of all "compile the .java file using c#.net" is an oxymoron.

However, you might really need an answer to different question: using Java language in .NET, then —

Why not?


First of all, it depends what do you call Java. I think you mean just Java programming language, so I don't see why not. I used to try out J#.

Let's try to find such things:

J# (http://en.wikipedia.org/wiki/J_Sharp) is Microsoft implementation, I used to try it with VS 2005; I don't remember is it supplied with later VS products but I think it can be installed -- please check up.

Ja.NET (http://www.janetdev.org) -- an open source implementation of a Java 5 JDK (Java development tools and runtime) for .NET

IKVM.NET (http://www.ikvm.net) -- 1) a Java Virtual Machine implemented in .NET; 2) a .NET implementation of the Java class libraries; 3) tools that enable Java and .NET interoperability.

Not too bad for first attempt to find results just from Wikipedia.

You may want to try out and consider sharing your experience.
Good luck! ;)
 
Share this answer
 
v7
Comments
fjdiewornncalwe 25-Dec-10 19:12pm    
You've made me think, SAKryukov, so there is no possible way I can vote on your answer on this one, but I have to comment that I think the OP means to attempt a compile of a java file using Studio without alteration as a C# project, in which case I think he as bigger problems with understanding than just the mechanics of finding a way to fit the square peg in the round hole.
Happy Holidays.
Kasson 27-Dec-10 0:19am    
Good Stuff. My 5 too.
Espen Harlinn 28-Feb-11 15:06pm    
IKVM.Net works just fine, my 5
Sergey Alexandrovich Kryukov 1-Mar-11 3:31am    
Thank you.
--SA
No. Java is java, and .Net is .Net.
 
Share this answer
 
Comments
Manfred Rudolf Bihy 25-Dec-10 9:08am    
Oh well, he could call javac from C# using the Process class of .NET :)
fjdiewornncalwe 25-Dec-10 19:10pm    
@Manfred.... Now you're just confusing the poor boy...
Sergey Alexandrovich Kryukov 25-Dec-10 22:31pm    
I must admit, this answer can be considered as correct; and I failed to see that "compile the .java file using c#.net" is just an oxymoron; and I'm sorry for my previous comment. In this way, the present answer is good and should be accepted. By the way, I never down-voted this answer.

However, if you consider that this question as just a sloppy formulation of "can I compile Java code with .NET?", it makes some sense, so does my answer (see).
Sergey Alexandrovich Kryukov 26-Dec-10 14:43pm    
John, if you said "Java is Java, C# is C#" (the question as posed is just an oxymoron), you would be quite right. But why Java (as a programming language) can't be used on .NET? (We're not discussing why?) -- see my answer.
Thank you.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900