Error : Could not create Java Virtual Machine when launching javaw - viewer - java

I'm launching javaw -viewer command through command prompt, I'm getting pop-up error message saying that,
Error : Coud not create Java Virtual Machine.
Error : A fatal exception has occured. Program will exit.
but the remaining command are working fine.
like java -version
See the image for error:
One more point I want to add, I'm running jdk1.7 also in my machine.

There's no such command as javaw -viewer. Perhaps you meant javaws -viewer?

Related

How to run a Java Swing application from Linux shell without a desktop environment?

I have an example Java application for testing. It uses the Java Swing library. I try running it with xserver in the Linux shell, so I'm not using a desktop environment.
Usually, you can run e.g. Firefox without problems like this:
startx /usr/bin/firefox
I tried exporting DISPLAY and running the application headless, but it only printed the first of the following lines.
{
System.out.println("This works");
JOptionPane.showMessageDialog(null, "This should show up");
}
If I run java -jar app.jar from the command line, I get a following error message:
Exception in thread "main" java.awt.HeadlessException: No X11 DISPLAY variable was set, but this program performed an operation which requires it.
With startx java -jar app.jar, the output is:
Bad command line option "-jar"
This should be:
startx /usr/bin/java -jar app.jar —-
Refer to https://askubuntu.com/questions/697978/how-to-pass-a-program-and-its-arguments-to-start or the startx manual page.
Edit: updated based on #chief654’s response.

Launch another JVM from Java with proxy arguments

I'm writting a Java Launcher Program, that should display installed Java programs and launch them, if needed.
Therefore i use the Runtime.getRuntime().exec() method with java.exe -jar myjar.jar as argument.
This works so far, but i also need to pass custom proxy settings to the jvm. From the command line this is possible with:
java.exe -http.proxyHost=www.example.com -http.proxyPort=80 -jar myjar.jar
But if i run this command in java it states:
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.
Unrecognized option: -http.proxyHost=www.example.com
So the question: Am i doing something wrong or is this not possible?
Thanks in Advance.
Runtime options should have a D at the beginning:
java.exe -Dhttp.proxyHost=www.example.com -Dhttp.proxyPort=80 -jar myjar.jar

Using mvnDebug crashes with 'Cannot load this JVM TI agent twice error'

I was building a simple project, a hello world example with teserract [1]. This worked fine in the Linux environment and when i tried it in the Mac it failed. So i wanted to debug the build process and see what's wrong. So i used,
mvnDebug clean install
but im getting this error immediately after running this,
ERROR: Cannot load this JVM TI agent twice, check your java command line for duplicate jdwp options.
Error occurred during initialization of VM
agent library failed to init: jdwp
Im using java 1.8. So what does this error means ?
[1] - https://github.com/nirojans/receipt-ocr
This means you're debbugging with duplicate arguments, check %JAVA_OPTIONS% in the log and remove one of these args and it should work!

How to initialize CommandLine class?

I am working with this command Line class of org.openqa.selenium.os package and wanted to execute a dir command get the output to my java code.
here is, what i have just tried,
String[] cmds={"date","dir"};
CommandLine cl=new CommandLine(cmds);
cl.execute();
System.out.println("The out put is "+cl.getStdOut());
i get this,
Exception in thread "main" java.lang.NullPointerException: Unable to find executable for: date
at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:236)
at org.openqa.selenium.os.UnixProcess.<init>(UnixProcess.java:61)
at org.openqa.selenium.os.CommandLine.<init>(CommandLine.java:47)
What i did wrong ? i jsut googled but no luck. you can also check this to know what CommandLine class does.
I am using Windows XP 32 bit and getting the same exception for all the commands.
In computing, CLS (for clear screen) is a command used by the command line interpreters COMMAND.COM and CMD.EXE on DOS, OS/2 and Microsoft Windows operating systems to clear the screen or console window of commands and any output generated by them.
see http://en.wikipedia.org/wiki/CLS_(command)
if you run cmd -c cls you will get your desired result

Error when running add-user.bat for Wildfly server

I'm trying to access the Administration console for Wildfly, but first it says I must
run the 'add-user.bat' file in [server installation directory]/bin/
Which I do but then get an error saying, well, look:
When I simply try and run the file by double clicking it I get:
I'm running Windows 8.1 64bit (Urgh) and Java 8
This might help. try using cmd /c add-user.bat or just run add-user.bat without any command before it and Check Java home path.

Categories

Resources