Click here to Skip to main content
15,878,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I have made an application in java which accepts arguments in main() function and then uses to process my data later on.

So far I have tried using:
VB
Dim startInfo As New ProcessStartInfo("java", "Launch java " & arguments)


where Launch is the name of the class, the 2nd java is part of the arguments, and the arguments are simply a string which is read initially.

Here is the code I have in java:

Java
import java.io.IOException;

public class Launch {

     public static void main(String[] args) {
        try {
            Process p = new ProcessBuilder(args).start();
            p.toString();

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}


I have tested out the java program manually using command line,
example:

java Launch java -XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump -Xmx1536M -Djava.library.path="C:\Users\User\AppData\Roaming/.minecraft/\versions\rd-132211\rd-132211_TagCraftMC" -cp "C:\Users\User\AppData\Roaming/.minecraft/\libraries\net\minecraft\\launchwrapper\1.6\launchwrapper-1.6.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\net\sf\jopt-simple\\jopt-simple\4.5\jopt-simple-4.5.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\org\ow2\asm\\asm-all\4.1\asm-all-4.1.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\net\java\jinput\\jinput\2.0.5\jinput-2.0.5.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\net\java\jutils\\jutils\1.0.0\jutils-1.0.0.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\org\lwjgl\lwjgl\\lwjgl\2.9.0\lwjgl-2.9.0.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\org\lwjgl\lwjgl\\lwjgl_util\2.9.0\lwjgl_util-2.9.0.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\org\lwjgl\lwjgl\\lwjgl-platform\2.9.0\lwjgl-platform-2.9.0-natives-windows.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\net\java\jinput\\jinput-platform\2.0.5\jinput-platform-2.0.5-natives-windows.jar";"C:\Users\User\AppData\Roaming/.minecraft/\libraries\net\java\jinput\\jinput-platform\2.0.5\jinput-platform-2.0.5-natives-windows.jar";"C:\Users\User\AppData\Roaming/.minecraft/\versions\rd-132211\rd-132211.jar" com.mojang.rubydung.RubyDung Ammar_Ahmad OFFLINE_MODE


However I am unable to get it to work programmatically using visual basic.
Any help regarding this would be really appreciated.

Thanks,
Ammar Ahmad
Posted
Comments
NeverJustHere 9-May-14 19:23pm    
Is it possibly related to the length of the arguments? Try with a shorter argument length. I have a vague recollection of a 255 character limit, but that may be on older version of windows.
Richard MacCutchan 10-May-14 4:15am    
What errors do you see? Are you sure that the java command is in the environment path?
Ammar_Ahmad 10-May-14 5:09am    
@Richard MacCutchan:
Seems like it wasn't, I have changed the code to:
<pre>System.Diagnostics.Process.Start("C:\Program Files\Java\jre8\bin\javaw.exe", "Launch")</pre>

which runs fine. Is there a way I can make the set java command in the environment path so that I can directly use?
<pre>System.Diagnostics.Process.Start("javaw", "Launch")</pre>

without hardcoded paths.
Richard MacCutchan 10-May-14 5:13am    
If you don't want to use hardcoded paths then you would have to ensure that the path is set in the environment before you start the program.

1 solution

I fixed the issue by making the application read the arguments from a text file and using eclipse to compile it to a .jar file. So now I can use process.start("filename.jar") to open it. Thanks.
 
Share this answer
 

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