I have the following code in the batch:
"C:/EDI_Module/jre1.8.0_121/bin/java" -Xms2g -Xmx10g -cp .;C:/EDI_Module/jar/;C:/EDI_Module/lib/; com/solverelogistics/edi/MainGenerator
Can you please tell me what is going on here? I know it runs some app. Which one is the java application?
The JRE executable (the bytecode interpreter):
"C:/EDI_Module/jre1.8.0_121/bin/java"
The starting memory size:
-Xms2g
The maximum memory size:
-Xmx10g
The classpath:
-cp .;C:/EDI_Module/jar/;C:/EDI_Module/lib/;
The class containing a public static void main method to execute:
com/solverelogistics/edi/MainGenerator
Note: I would have typically expect the class to look something like this com.solverelogistics.edi.MainGenerator, with ., not /.
Related
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
This is my exact batch file. I have tried to convert it doing some research online and get an error
"Failed to execute child process "/home/pi/Desktop/TeachVal/TeachValLinuxShell" (No such file or directory)
echo off
cls
echo Running TeachVAL II...
set path=%path%;/Library/Java/JavaVirtualMachines/jdk1.8.0_65.jdk/Contents/Home/bin
java -classpath comm.jar;Robot.jar;TeachVAL TeachVAL
cls
exit
This one is my attempt at translating.
#!/bin/bash
set +v
clear
echo "Running TeachVAL II..."
java -cp ".dir1;dir2;path/home/pi/Desktop/TeachVAL/comm.jar;
path/home/pi/Desktop/TeachVAL/Robot.jar;/home/pi/Desktop/TeachVAL/TeachVAL"
clear
exit
Welcome to Linux--life is good here, but there are a few things that work slightly differently, when compared to Windows.
One difference is that Windows uses semicolon (;) to separate entries in a list of paths, but Linux uses colons (:) for that purpose.
So, the Windows command:
java -classpath comm.jar;Robot.jar;TeachVAL TeachVAL
would correspond to this on Linux:
java -classpath comm.jar:Robot.jar:TeachVAL TeachVAL
In general, on Linux, semicolons are used to put multiple command lines into a single line. Once you've learned that, I think you can then understand why:
java -cp .dir1;/home/pi/Desktop/TeachVAL/TeachVAL
would be the same as:
java -cp .dir1
/home/pi/Desktop/TeachVAL/TeachVAL
That would run java (with no class to be executed) and then try to run "/home/pi/Desktop/TeachVAL/TeachVAL" which can't be found.
There are many more differences to learn; here's a page that will help you get started: http://tldp.org/LDP/abs/html/dosbatch.html
I'm new in the Oracle world and I'm working with Oracle Identity Analytics (OIA). In the test environment everything is ok, but in production environment i'm getting an "java.lang.OutOfMemoryError", so when I checked the Xmx and Xms I saw that I had Xmx:512m and Xms:512m, that's why I'm trying to modify the Xmx value.
I want to modify the Xmx and Xms values so I wrote the following line in my PuTTY:
$ java -Xmx1024m
But the PuTTY shows me the following:
Usage: java [-options] class [args...] (to execute a class) or
java [-options] -jar jarfile [args...] (to execute a jar file)
where options include:...
Seems like I'm forgetting something after "Xmx1024m", but what? Well, now I know I'm forgetting Jar file, Class or App name but I have no idea how to get any of those things. I tried putting "$AdminServer" after "Xmx1024m" but it didn't work.
My Java version is 1.6.0_45 Oracle JRockit build R28 and the Operative Systems is Linux Server 6.5.
Regards!
You have to pass filepath to execute. Of course, you can run
java -Xmx1024m
but Java doesn't know what file should be executed
You will have to pass the program-name/filename/jar-name,whatever it is,with path for which you want to set/reset the java heap size.
e.g
java -Xms1024M -Xmx2048M -jar xi.jar
java -Xmx64m ${PROGRAM_NAME}
Hope this helps you.Or to help you better,could you please tell us what exactly is your scenario?
I'm writing a simple batch script to execute a game quicker (for a dev environment purpose), however I seem to be unable to pass the appropriate command-line arguments to the executable:
#ECHO OFF
set USERNAME=Testing
set MCDIR=%APPDATA%/.minecraft/
set GAMEDIR=%MCDIR%/versions/1.7.5/
set NATIVES=%GAMEDIR%/natives/
java -client -Xmx512M -Xms512M ^
-Djava.library.path=%NATIVES% ^
-cp %GAMEDIR%/1.7.5.jar:^
%MCDIR%/libraries/java3d/vecmath/1.3.1/vecmath-1.3.1.jar:^
%MCDIR%/libraries/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar:^
##etc... lots of libs
%MCDIR%/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.1/lwjgl_util-2.9.1.jar:^
%MCDIR%/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.1/lwjgl-platform-2.9.1-natives-windows.jar:^
%MCDIR%/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar:^
net.minecraft.client.main.Main --username=%USERNAME% --version 1.7.5 --gameDir %MCDIR% --assetsDir %MCDIR%/assets --userProperties {} --accessToken Offline
pause
However this small script seems to fail the instant it goes beyond client.main.Main with any argument, effectively treating it as a JVM argument rather than a command-line program argument. Is there a different way to go about doing this when using -cp rather than -jar for calling a program in java? If not, what am I doing wrong?
It appears that there is no space between the end of your path (the last ^) and your Main class, so your Main class is effectively part of the -cp JVM argument. There is no class yet, so java still sees JVM args.
Try putting a space after the last part of the -cp value and your net.minecraft.client.main.Main, to separate the -cp value and your class on the command line.
I have a .JAR that apparently uses up too much memory, and throws an exception "Java heap space" (or something similar).
So I tried running the .JAR via the CMD like this:
C:\MyFolder>javaw -jar MyJar.jar -Xms64m -Xmx128m
That did not solve the problem. Same error.
Now, when I checked the Processes tab in the windows task manager, I noticed that the process of my jar has a lot less memory than what i asked for (same as running it without the parameters).
Why is it ignoring the parameters?
Also, I think the exception is thrown around the time the process reaches 100mb of memory usage. Is it possible that the GC is trying to free up the memory and that's what causes the problem? Is there any parameter I can set for the GC to prevent that?
Thanks, Malki :)
The Command
javaw -jar MyJar.jar -Xms64m -Xmx128m
will use -Xms... and -Xmx... as parameters to the "main(String[] args)" method.
Parameters to the JVM must be passed before the -jar part:
javaw -Xms64m -Xmx128m -jar MyJar.jar
The reason for that can be seen when we execute "java -version" :
Usage: java [-options] class [args...]
(to execute a class)
or java [-options] -jar jarfile [args...]
(to execute a jar file)
Where your parameters -Xms... and -Xmx... are options to the JVM.