Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Java
  4. Calling java method from C# .net

Calling java method from C# .net

Scheduled Pinned Locked Moved Java
csharptutorialjavaalgorithmsquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • K Offline
    K Offline
    KASR1
    wrote on last edited by
    #1

    I have written a function in JAVA and i need to call that function from C# .net. While searching on the net, most of them suggesting to use 3rd party(like JNBridge) to create wrapper DLL and that can be referenced in C# .net. But i don't want to use 3rd party. How to develop a wrapper in order to access java from C#? Any example code may be more helpful.

    N T D 3 Replies Last reply
    0
    • K KASR1

      I have written a function in JAVA and i need to call that function from C# .net. While searching on the net, most of them suggesting to use 3rd party(like JNBridge) to create wrapper DLL and that can be referenced in C# .net. But i don't want to use 3rd party. How to develop a wrapper in order to access java from C#? Any example code may be more helpful.

      N Offline
      N Offline
      Nagy Vilmos
      wrote on last edited by
      #2

      I'm afraid you'll need to have some form of bridge software. Have a read of this article[^], it explains the issues and gives you the software you need. Re-inventing the wheel is not a good idea.


      Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

      D 1 Reply Last reply
      0
      • K KASR1

        I have written a function in JAVA and i need to call that function from C# .net. While searching on the net, most of them suggesting to use 3rd party(like JNBridge) to create wrapper DLL and that can be referenced in C# .net. But i don't want to use 3rd party. How to develop a wrapper in order to access java from C#? Any example code may be more helpful.

        T Offline
        T Offline
        TorstenH
        wrote on last edited by
        #3

        now the question is not if or how a JAVA function can be called in C#. The real question must be: why? Why did you write "a function" in JAVA? Why didn't you write "a function" in C# as you are using C# surround "a function". And beside of that am I wondering what "a function" might be and why it is called directly from a C# code. Java can be a mighty beauty when written by an expert, but it needs a little more than "a function"-header to address a java code. Isn't there any network related stuff involved?

        regards Torsten When I'm not working

        K 1 Reply Last reply
        0
        • N Nagy Vilmos

          I'm afraid you'll need to have some form of bridge software. Have a read of this article[^], it explains the issues and gives you the software you need. Re-inventing the wheel is not a good idea.


          Panic, Chaos, Destruction. My work here is done. Drink. Get drunk. Fall over - P O'H OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett

          D Offline
          D Offline
          David Skelly
          wrote on last edited by
          #4

          He's already got this answer on the C# forum. I think he has decided to go the JNI route and is looking for pointers on that so has re-posted here.

          1 Reply Last reply
          0
          • K KASR1

            I have written a function in JAVA and i need to call that function from C# .net. While searching on the net, most of them suggesting to use 3rd party(like JNBridge) to create wrapper DLL and that can be referenced in C# .net. But i don't want to use 3rd party. How to develop a wrapper in order to access java from C#? Any example code may be more helpful.

            D Offline
            D Offline
            David Skelly
            wrote on last edited by
            #5

            This article may get you started: How to Call Java Functions from C Using JNI[^] It's a bit basic but it might at least point you in the right direction. But JNI programming is not straight-forward at the best of times, and the benefits of using a third-party tool are that they have worked out all the difficult bits, and it may end up being cheaper in the long run to buy something off the shelf than to spend ages building your own.

            K 1 Reply Last reply
            0
            • T TorstenH

              now the question is not if or how a JAVA function can be called in C#. The real question must be: why? Why did you write "a function" in JAVA? Why didn't you write "a function" in C# as you are using C# surround "a function". And beside of that am I wondering what "a function" might be and why it is called directly from a C# code. Java can be a mighty beauty when written by an expert, but it needs a little more than "a function"-header to address a java code. Isn't there any network related stuff involved?

              regards Torsten When I'm not working

              K Offline
              K Offline
              KASR1
              wrote on last edited by
              #6

              Becoz JAVA has classes to support zip file compresion/decompression of multiple files. The same feature is not available in C#. Only through 3rd party its achivable. So i prefer to write a dll in java and use it in C#. Is there any alternate solutions?

              T 1 Reply Last reply
              0
              • D David Skelly

                This article may get you started: How to Call Java Functions from C Using JNI[^] It's a bit basic but it might at least point you in the right direction. But JNI programming is not straight-forward at the best of times, and the benefits of using a third-party tool are that they have worked out all the difficult bits, and it may end up being cheaper in the long run to buy something off the shelf than to spend ages building your own.

                K Offline
                K Offline
                KASR1
                wrote on last edited by
                #7

                Thanks to all for the suggesstions.

                1 Reply Last reply
                0
                • K KASR1

                  Becoz JAVA has classes to support zip file compresion/decompression of multiple files. The same feature is not available in C#. Only through 3rd party its achivable. So i prefer to write a dll in java and use it in C#. Is there any alternate solutions?

                  T Offline
                  T Offline
                  TorstenH
                  wrote on last edited by
                  #8

                  one can not zip multiple files in C#??? :omg: Not really true eh! Think about it. This MUST be possible. Ask the C# guys. Using some Java code found on the web in a C# environment can't be a solution.

                  regards Torsten When I'm not working

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups