Converting Java to C#

  • Thread starter Thread starter Jay
  • Start date Start date
J

Jay

I've downloaded some Java files from the internet, and want to use them as a
basis for a C# programme.

They are .jar files, and when I open them in Notepad, they are not text
files.

Is there a way to get some sort of source code from them?

Sorry if this sounds a bit basic, but I've never used Java before.
 
Hi Jay,

This is hardly a newsgroup for java questions.

JAR files are Java ARchive files that can be decompressed using the JAVA SDK jar tool or WinRar or similar (may not work well with WinZip)
 
I've downloaded some Java files from the internet, and want to use them as a
basis for a C# programme.

They are .jar files, and when I open them in Notepad, they are not text
files.

Is there a way to get some sort of source code from them?

Sorry if this sounds a bit basic, but I've never used Java before.

Well, you could decompile them - but to do so without the permission of
the author is somewhat unethical and could well be illegal depending on
the licence.

Basically, think of jar files as rough equivalents of .NET assemblies.
(It's not that straightforward, but basically they contain the compiled
classes, rather than being source files.)
 
Jay said:
They are .jar files, and when I open them in Notepad,
they are not text files.

Jar files are binaries, broadly equivalent to .NET's exe files. They
aren't source code.
Is there a way to get some sort of source code from them?

Short of disassembly, which won't give you the useful bits like
variable names, no. I think source code files in Java usually take a
..java extension.

Eq.
 
They are .jar files, and when I open them in Notepad, they are not text
files.

Is there a way to get some sort of source code from them?

I concur with the others. There are many tools to disassemble them
back into java source files, but that may not be legal.

Or you can run them "as is" with ikvm in .NET.

Eric
 
Thanks for your replies everyone.

I wondered myself if it was a good idea to ask the question on this forum,
so sorry if it was the wrong place.

On the ethical question, the Java files are from an company that want people
to use their API, and they provide the Java files as an example of their
use, so I'm assuming that it is OK to convert them. I do intend to ask them
if this is OK, but doing so, wanted to see if they would be any use to me.

Jay


"Jay" <-> wrote in message I've downloaded some Java files from the internet, and want to use them as a
basis for a C# programme.

They are .jar files, and when I open them in Notepad, they are not text
files.

Is there a way to get some sort of source code from them?

Sorry if this sounds a bit basic, but I've never used Java before.
 
On the ethical question, the Java files are from an company that want people
to use their API, and they provide the Java files as an example of their
use, so I'm assuming that it is OK to convert them.

If they want these java files to serve as an example, then they surely
must provide the java source code. It makes no sense to distribute a
binary file as an example of how to use an API.

I see Java as mostly a subset of C#, so a port from Java to C# is
usually trivial unless it's a big project.

Eric
 
Back
Top