java -jar illegal argument - java

I am trying to run a jar file from windows command line like this:
java -jar myjar.jar
and i get the following error msg
-jar: illegal argument
usage: java [-options] class
where options include:
-help print out this message
-version print out the build version
-v -verbose turn on verbose mode
-debug enable remote JAVA debugging
-noasyncgc don't allow asynchronous garbage collection
-verbosegc print a message when garbage collection occurs
-noclassgc disable class garbage collection
-ss<number> set the maximum native stack size for any thread
-oss<number> set the maximum Java stack size for any thread
-ms<number> set the initial Java heap size
-mx<number> set the maximum Java heap size
-classpath <directories separated by semicolons>
list directories in which to look for classes
-prof[:<file>] output profiling data to .\java.prof or .\<file>
-verify verify all classes when read in
-verifyremote verify classes read in over the network [default]
-noverify do not verify any class
-nojit disable JIT compiler
anybody knows why that might be?

If you're using Windows Command Line, you can use javaw youJarFile.jar

Related

Why does it say -jar is illegal argument when try to run java?

Command line: java -jar myjar.jar
-jar: illegal argument
usage: java [-options] class
where options include:
-help print out this message
-version print out the build version
-v -verbose turn on verbose mode
-debug enable remote JAVA debugging
-noasyncgc don't allow asynchronous garbage collection
-verbosegc print a message when garbage collection occurs
-noclassgc disable class garbage collection
-ss<number> set the maximum native stack size for any thread
-oss<number> set the maximum Java stack size for any thread
-ms<number> set the initial Java heap size
-mx<number> set the maximum Java heap size
-classpath <directories separated by semicolons>
list directories in which to look for classes
-prof[:<file>] output profiling data to .\java.prof or .\<file>
-verify verify all classes when read in
-verifyremote verify classes read in over the network [default]
-noverify do not verify any class
-nojit disable JIT compiler

JMeter Dashboard Generation Java Heap Space

I've been able to create dashboards for small amounts of log data (3mb) with JMeter. However, when trying to create dashboards with large amounts of data (35mb), jmeter will throw a java.lang.OutOfMemoryError: Java Heap Space.
So far I've tried to create an environment variable called JVM_ARGS=-Xms1024m -Xmx10240m but I still do not have enough space.
Is there anything else I can try to create these dashboards? Or is there a way to reduce the number of entries that get written to the log file?
Thank you!
There are 2 possibilities :
Option 1 : your JVM options are not taken into account. Show the first lines or all content of jmeter.log
Option 2 : you have added some dynamic parameter to your http requests that has created a lot of different (name) SampleResult
Edit 8 october 2018:
Root cause was point Option 2
Make sure you've really created the environment variable and it has the anticipated value, double check this by running the following command in the terminal window where you will be launching JMeter from:
echo %JVM_ARGS% for Windows
echo $JVM_ARGS for Linux/Unix/MacOS
You should see your increased JVM heap settings
Make sure to use either jmeter.bat for Windows or jmeter.sh for other operating systems wrapper script
Make sure to use 64-bit version of JRE as 32-bit will not be able to allocate more than 3G heap
Make sure you can execute java command with your 10G heap
java -Xms1024m -Xmx10240m -version
you should see your Java version
Try running ApacheJMeter.jar executable directly:
java -Xms1024m -Xmx10240m -jar ApacheJMeter.jar -g result.jtl -o destination_folder
If nothing helps be aware that you can generate tables/charts using JMeterPluginsCMD Command Line Tool (it is not a part of standard JMeter installation, can be installed using JMeter Plugins Manager)

How to use jps -Joption

I really can't figure out how to use jsp -Joption. I got description as followed,
OPTIONS
The jps command supports a number of options that modify the output of the command. These options are subject to change or removal in the
future.
-q Suppress the output of the class name, JAR file name, and arguments passed to the main method, producing only a list of
local VM identifiers.
-m Output the arguments passed to the main method. The output may be null for embedded JVMs.
-l Output the full package name for the application's main class or the full path name to the application's JAR file.
-v Output the arguments passed to the JVM.
-V Output the arguments passed to the JVM through the flags file (the .hotspotrc file or the file specified by the
-XX:Flags=<filename> argument).
-Joption Pass option to the java launcher called by javac. For example, -J-Xms48m sets the startup memory to 48 megabytes. It is a
common convention for -J to pass options to the underlying VM executing applications written in Java.
Actually, I don't know what is a java launcher called by javac, and when I run the example jps -J-Xms48m just as same using jps. So, what this option for? Thanks.
Java development tools like jps, jstat, jstack, jmap etc. are all written in Java. Just like regular Java programs they require Java Runtime Environment, i.e. they run under JVM.
-J options do not affect jps tool directly, but they rather affect the JVM which runs this tool. E.g. -J-Xms48M option means that jps will launch Java Virtual Machine with the initial heap size of 48 Megabytes.
For example, compare jps -J-XX:+PrintGCDetails and jps -J-Xms48M -J-XX:+PrintGCDetails

powershell java invalid thread stack size error

I'm tasked with converting some Windows scripts to PowerShell versions. The conversion is going good except for some minor issues. Top issue involves a Java call that we use to query a database and generate XML or HTML files. When I run this from a Windows script no problem:
java -Xss1m -cp ../lib/;../lib/jtds-1.3.1.jar;../lib/ojdbc6.jar DBDownloader TMPDBNAME ../sql/MTD_MTTR_Detail_v7.sql ../out/drilldown/%fileName1% >> ..\logs\mtd.log 2>&1
But when I run this from a PowerShell script I get this error:
LASTEXITCODE:1 Error: Could not create the Java Virtual Machine. Error: A fatal exception has occurred. Program will exit.
Invalid thread stack size: -Xss1m -cp
The call is made using the & call operator. I wrote a library function for all the script to use and it make a call similar to the following:
*$output = [string] (& $jvApp $jvArg1 $jvArg2 $jvArg3 $dbArg $sqlArg $lastArg >> $logArg 2>&1)
The args for this call are the following:
sqlName: MTD_MTTR_Detail_v7
jvArg1: -Xss1m -cp
jvArg2: ../lib/;../lib/jtds-1.3.1.jar;../lib/ojdbc6.jar
jvArg3: DBDownloader
dbArg: TMPDBNAME
sqlArg: ..\sql\MTD_MTTR_Detail_v7.sql
lastArg: ..\out\drilldown\MTD_MTTR_Detail.xml
logArg: ..\logs\mtd.log
I also set these environment variables:
env:Path: C:\Program Files\Java\jre8\bin;...
env:JAVA_HOME: C:\Program Files\Java\jre8\;
env:CLASSPATH: C:\Program Files\Java\jre8\lib;
What is weird is that the call will work and produce the XML or HTML file if I take out the stack size argument. I've also tried several smaller stack size settings down to 128k with no luck.
While the call works now without the setting, I'm concerned it may fail in the future. I believe they put this due the complex SQL statement used the large amounts of data they were querying and processing.
Any ideas?
SOLVED: When I split up the two args in jvArg1 into two different variables the Java call worked with no stack size error. I guess Java was reading the first arg as one big string and the space in between didn't matter. It must have thought the -cp was part of the stack size argument.

Get the name of the java process instead of pid?

jps.exe which found on JDK 1.5 and later could monitor all Java process but is there a way to detect the specify command line and terminate the correct pid?
What if the user have JRE, is there a similar code allow us to terminate any process easily?
Prefer to keep the topic on Windows which I am working on.
The jps command supports a number of options that modify the output of the command. These options are subject to change or removal in the future.
-q Suppress the output of the class name, JAR file name, and arguments passed to the main method, producing only a list of local VM identifiers.
-m Output the arguments passed to the main method. The output may be null for embedded JVMs.
-l Output the full package name for the application's main class or the full path name to the application's JAR file.
-v Output the arguments passed to the JVM.
-V Output the arguments passed to the JVM through the flags file (the .hotspotrc file or the file specified by the -XX:Flags= argument).
Pipe the output of jps to grep or sed or awk or perl or even another Java program for further matching, parsing and action. On Windows, the easiest way to get those utilities is through Cygwin.
Here are some Microsoft downloadable command line utilities which are useful for working with processes on Windows:
pskill
pslist
and the rest of the Sysinternals Suite
If the user don't have jps, you can use ps. The command line options for ps differs between platforms, see man ps on you system. I use ps -C java -o pid,time,cmd to list java processes on a CentOS system. Then kill to terminate.

Categories