Results 1 to 6 of 6

Thread: Run java program from VB.net

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    10

    Run java program from VB.net

    i want call a java class file (no gui) from a vb application.
    the java class will output some text on screen and i want to redirect the output to the vb program.

    is there any ways to do it?


    thanks~

  2. #2
    KrisSiegel.com Kasracer's Avatar
    Join Date
    Jul 2003
    Location
    USA, Maryland
    Posts
    4,985

    Re: Run java program from VB.net

    I don't know much baout Java, but if you can run the class from the command prompt, then you can use the Process.Start() to run the class.

    Though getting the output would be even more difficult.

    Since .Net and Java are fairly similar, why not port the class? That would eliminate another dependency your app would have and keep it running quicker because it's in 1 application instead of two.
    KrisSiegel.com - My Personal Website with my blog and portfolio
    Don't Forget to Rate Posts!

    Free Icons: FamFamFam, VBCorner, VBAccelerator
    Useful Links: System.Security.SecureString Managed DPAPI Overview Part 1 Managed DPAPI Overview Part 2 MSDN, MSDN2, Comparing the Timer Classes

  3. #3
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Run java program from VB.net

    You cannot directly access a Jave class in your .NET app. You can execute any executable, Java or otherwise, using Process.Start, but you cannot access Java objects directly within your .NET code. You can create a ProcessStartInfo object and set its RedirectStandardOutput to True, pass it to Process.Start and save the Process object it returns, then read from the StandardOutput stream of the Process. You should read about the Process and ProcessStartInfo classes.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4

    Thread Starter
    New Member
    Join Date
    Jan 2005
    Posts
    10

    Re: Run java program from VB.net

    Quote Originally Posted by jmcilhinney
    You cannot directly access a Jave class in your .NET app. You can execute any executable, Java or otherwise, using Process.Start, but you cannot access Java objects directly within your .NET code. You can create a ProcessStartInfo object and set its RedirectStandardOutput to True, pass it to Process.Start and save the Process object it returns, then read from the StandardOutput stream of the Process. You should read about the Process and ProcessStartInfo classes.
    I see. That really what I want to do.

    But I have another question.
    How can I check whether a JRE program is installed in the machine from the vb.net program?
    Or I can only check the environment variables "JAVA_HOME" instead?

  5. #5
    New Member
    Join Date
    Sep 2012
    Posts
    10

    Re: Run java program from VB.net

    Quote Originally Posted by jmcilhinney View Post
    you cannot directly access a jave class in your .net app. You can execute any executable, java or otherwise, using process.start, but you cannot access java objects directly within your .net code. You can create a processstartinfo object and set its redirectstandardoutput to true, pass it to process.start and save the process object it returns, then read from the standardoutput stream of the process. You should read about the process and processstartinfo classes.
    can u please write a detailed code of it in .net

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Run java program from VB.net

    Quote Originally Posted by sanjeev467 View Post
    can u please write a detailed code of it in .net
    There's an example in the VB.NET CodeBank forum, posted by gigemboy.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width