3

So, I have written my code to .zip files in C#, but when I import the libraries I have the following:

Using java.util;
Using java.util.zip;
Using java.io;

But, these are underlined in red, with the error message, The type or namespace "java" could not be found

Is there some reference I need to add?

1

4 Answers 4

11

You can't import Java libraries directly to .NET.

You should use IKVM if you want to use Java in .NET, though there are zip libraries for .NET - here is one, SharpZipLib.

Additionally, the syntax is using, not Using - it is all lower case.

Sign up to request clarification or add additional context in comments.

Comments

6

Well unless you're using J# (which became obsolete quite a while ago) you shouldn't be trying to use Java libraries in .NET. You should use the .NET framework libraries instead.

If you want a port of the Java zip libraries to .NET, there's one available at SharpZipLib. That should make it reasonably easy to port your C# code to use the right libraries - but for almost all tasks, you shouldn't be trying to use anything from Java; you should use the idiomatic .NET-based tool which solves the same problem. Sometimes there's a project which shares the same philosophies and possibly original implementation roots (e.g. NHibernate for Hibernate) but sometimes there are completely different options available.

Comments

4

There is no way to import an actual Java library into c#. You may want to consider looking at jni4net - "bridge between Java and .NET".

Comments

0

Actually, you can. One word - JavApi.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.