2

I used to launch a java tool with a batch like this :

java -classpath "./lib/JSanExport.jar;./lib/JSanRmiApiEx.jar;./lib/JSanRmiServerUx.jar" -Xms128M -Xmx768M -Dmd.command=command_VSPLA.txt -Dmd.logpath=log sanproject.getmondat.RJMdMain

For some reasons i need to convert that batch into a Powershell script. But when I copy the same line on my powershell script I got an error, whereas I launch it in the same workingdir.

c:\Program Files\ExportTool\export>powershell .\Run_VSPLA.ps1
Exception in thread "main" java.lang.NoClassDefFoundError: /command=command_VSPLA/txt
Caused by: java.lang.ClassNotFoundException: .command=command_VSPLA.txt
    at java.net.URLClassLoader$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
    at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
    at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: .command=command_VSPLA.txt.  Program will exit.

Do you know what happens?

2 Answers 2

2

try to set jvm options before classpath :

java -Xms128M -Xmx768M -Dmd.command=command_VSPLA.txt -Dmd.logpath=log  -classpath "./lib/JSanExport.jar;./lib/JSanRmiApiEx.jar;./lib/JSanRmiServerUx.jar" sanproject.getmondat.RJMdMain

It searches for class named /command=command_VSPLA/txt. For batch = is a delimiter and is parsed in a different way than powershell.

EDIT

The solution given by the OP:

java -Xms128M -Xmx768M "-Dmd.command=.\command_VSPLA.txt" "-Dmd.logpath=log" -classpath "./lib/JSanExport.jar;./lib/JSanRmiApiEx.jar;./lib/JSanRmiServerUx.jar" sanproject.getmondat.RJMdMain
Sign up to request clarification or add additional context in comments.

4 Comments

You got no other idea? :(
You can try with start-process cmdlet and separate string for arguments : ss64.com/ps/start-process.html .That way you should have more control over the parameters...
Didnt work but helped me a lot :) Here is the solution if you can edit your answer i'll give it as accepted: java -Xms128M -Xmx768M "-Dmd.command=.\command_VSPLA.txt" "-Dmd.logpath=log" -classpath "./lib/JSanExport.jar;./lib/JSanRmiApiEx.jar;./lib/JSanRmiServerUx.jar" sanproject.getmondat.RJMdMain
ahaa.Great work.Quotes prevent jvm options to be taken as two different parameters.Should thought for this myself :-)
0

Seem like it can't find command_VSPLA.txt, maybe try a full path.

1 Comment

Dosn't change anything : c:\Program Files\ExportTool\export>powershell .\Run_VSPLA.ps1 Exception in thread "main" java.lang.NoClassDefFoundError: /command=C:\Program Files\ExportTool\export\command_VSPLA/txt Caused by: java.lang.ClassNotFoundException: .command=C:\Program Files\ExportTool\export\command_VSPLA.txt at java.net.URLClassLoader$1.run(Unknown Source) (...)at java.lang.ClassLoader.loadClass(Unknown Source) Could not find the main class: .command=C:\Program Files\ExportTool\export\command_VSPLA.txt. Program will exit.

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.