Can't Start Minecraft with Command Line - java

I tried to start minecraft with these args:
arguments = ["javaw.exe", "-Xmx"+str(max_mem), "-XX:+UseConcMarkSweepGC", "-XX:+CMSIncrementalMode",
"-XX:-UseAdaptiveSizePolicy", "-Xmn"+str(min_mem),
"-XX:HeapDumpPath=MojangTricksIntelDriversForPerformance_javaw.exe_minecraft.exe.heapdump",
"-Djava.library.path="+natives_dir, "-Dminecraft.launcher.brand=java-minecraft-launcher",
"-Dminecraft.launcher.version=1.6.89-j",
"-cp "+libraries,
"net.minecraft.client.main.Main", "--username "+player, "--version "+MINECRAFT_VERSION,
"--accessToken 0", "--userProperties {}", "--gameDir "+CLIENT_PATH, "--assetsDir "+assets_dir,
"--assetIndex ", "--width "+width, "--height "+height]
However, I receive this error:
Unrecognized option: -cp C:/Users/danch/AppData/Roaming/.launcor/libraries/ca/weblite/java-objc-bridge/1.0.0/java-objc-bridge-1.0.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/google/guava/guava/21.0/guava-21.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/mojang/authlib/1.5.25/authlib-1.5.25.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/mojang/patchy/1.1/patchy-1.1.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/mojang/realms/1.10.22/realms-1.10.22.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/paulscode/codecwav/20101023/codecwav-20101023.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/commons-codec/commons-codec/1.10/commons-codec-1.10.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/commons-io/commons-io/2.5/commons-io-2.5.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/io/netty/netty-all/4.1.9.Final/netty-all-4.1.9.Final.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-windows.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/lwjgl/lwjgl/lwjgl/2.9.2-nightly-20140822/lwjgl-2.9.2-nightly-20140822.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.2-nightly-20140822/lwjgl-platform-2.9.2-nightly-20140822-natives-windows.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.2-nightly-20140822/lwjgl_util-2.9.2-nightly-20140822.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar;C:/Users/danch/AppData/Roaming/.launcor/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar;C:/Users/danch/AppData/Roaming/.launcor/versions/1.12.2/1.12.2.jar
What did I do wrong?

It's not
"-cp "+libraries,
it is
"-cp",
libraries,
Everywhere you would type a space on the command line is a new argument! So you have to change this in multiple places.

Maybe try -classpath instead of -cp.
Not sure if that's because of your Java version or what.

Related

Get specific java version with powershell

I have some issues with getting the java version out as a string.
In a batch script I have done it like this:
for /f tokens^=2-5^ delims^=.-_^" %%j in ('%EXTRACTPATH%\Java\jdk_extract\bin\java -fullversion 2^>^&1') do set "JAVAVER=%%j.%%k.%%l_%%m"
The output is: 1.8.0_121
Now I want to do this for PowerShell, but my output is: 1.8.0_12, I miss one "1" in the end Now I have tried it with trim and split but nothing gives me the right output can someone help me out?
This is what I've got so var with PowerShell
$javaVersion = (& $extractPath\Java\jdk_extract\bin\java.exe -fullversion 2>&1)
$javaVersion = "$javaVersion".Trim("java full version """).TrimEnd("-b13")
The full output is: java full version "1.8.0_121-b13"
TrimEnd() works a little different, than you might expect:
'1.8.0_191-b12'.TrimEnd('-b12')
results in: 1.8.0_19 and so does:
'1.8.0_191-b12'.TrimEnd('1-b2')
The reason is, that TrimEnd() removes a trailing set of characters, not a substring. So .TrimEnd('-b12') means: remove all occurrences of any character of the set '-b12' from the end of the string. And that includes the last '1' before the '-'.
A better solution in your case would be -replace:
'java full version "1.8.0_191-b12"' -replace 'java full version "(.+)-b\d+"','$1'
Use a regular expression for matching and extracting the version number:
$javaVersion = if (& java -fullversion 2>&1) -match '\d+\.\d+\.\d+_\d+') {
$matches[0]
}
or
$javaVersion = (& java -fullversion 2>&1 | Select-String '\d+\.\d+\.\d+_\d+').Matches[0].Groups[0].Value

Calling java command line applications

So I have the following command that runs java application from the command line and produces a bunch of output.
java -jar client.jar --server test7.contoso.com --alternativeemailaddress fred1#contoso.com --organisation contoso --emailaddress fred#contoso.com --data1 1234 --Password1 123456 --data2 1234 --Password2 1234
I'm trying to run this from within PowerShell and capture the output to a variable for further processing.
So far I've found 100's of different ways to do this, but none have really worked particularly well.
Is there any best practice/convention as to how to get this done?
See: https://blogs.technet.microsoft.com/josebda/2012/03/03/using-windows-powershell-to-run-old-command-line-tools-and-their-weirdest-parameters/
For many ways to execute "legacy" commands with PowerShell
You need to include the .exe for one.
The new V3+ recommended way is to use --% to tell PowerShell to not parse the remaining arguments
PS> java.exe --% -jar client.jar --server test7.contoso.com --alternativeemailaddress fred1#contoso.com --organisation contoso --emailaddress fred#contoso.com --data1 1234 --Password1 123456 --data2 1234 --Password2 1234
OK so I worked it out. This is what I went with.
$params = #{ 'jar'='C:\client\client.jar';
'param1'='data1'
'param2'='data2'
'param3'='data3'
'param4'='data4'
'param5'='data5'
'param6'='data6'
'param7'='data7'
'param8'='data8'
'param9'='data9'
'param10'='data10'
'error_log'='C:\tmp\error_log.txt'
}
$data = & 'C:\Program Files\java\jdk1.8.0_121\bin\java.exe' -jar $params.'jar' `
--param1 $params.param1 `
--param2 $params.param2 `
--param3 $params.param3 `
--param4 $params.param4 `
--param5 $params.param5 `
--param6 $params.param6 `
--param7 $params.param7 `
--param8 $params.param8 `
--param9 $params.param9 `
--param10 $params.param10 `
2>$params.error_log

Batch to call Java main class

I am getting an error for below batch file.
cls
set classpath=C:\Program^ Files\salesforce.com\Data^ Loader\dataloader-29.0.0-uber.jar
set mainclass=com.salesforce.dataloader.process.ProcessRunner
set confdir=C:\Program^ Files\salesforce.com\Data^ Loader\Bkp\
if [%1]==[] goto error
call java -cp %classpath% -Dsalesforce.config.dir=%confdir% %mainclass% process.name=Product_vod__c sfdc.extractionSOQL="SELECT
Id,name FROM Product_vod__c where Id in %1"
goto end
:error
echo Error: missing date argument (must be in 'yyyy-mm-ddThh:mm:ssZ' format)
:end
Error
Could not find or load main class Files\salesforce.com\Data
Can someone please let me know the issue?
Thanks
You've got an unescaped Program Files somewhere in your classpath and its space breaks the classpath argument : the classpath stops at Program and java parses the following Files\salesforce.com\Data as the class it should execute.
You should enclose classpath fragments containing spaces with double-quotes.

BeanShell command line interpreter features

I'm trying to test BeanShell's command line interpreter in how it processes basic Java commands and syntax on my machine, and see if I can customise its behavior in any way. I've installed version 2.0b4 on my machine running OS X 10.10.1 (the JAR file is in /Library/Java/Extensions as per the instructions).
It's the closest thing to what I've been looking for, an interactive Java interpreter, but it doesn't have some standard features which a good interpreter should have.
I'd like to be able to use the Up arrow key to reuse a previous command, but at the moment it doesn't recognise it, it just shows a control sequence. Is there a way to customise this for BeanShell?
Is there a way to get BeanShell to print out the value of a variable if I've created it beforehand, just by naming it, like
String s = new String( "Hello World!" );
s;
Hello World!.
This is possible in Python for example.
According to the documentation on importing Java classes which(<java class>); should return the classpath location of the specified Java class. But which( java.lang.String ); does not work for me, I get a NullPointerException:
bsh % which(java.lang.String);
Start ClassPath Mapping
Mapping: Directory /Users/srm
// Error: // Uncaught Exception: Method Invocation cp.getClassSource : at Line: 42 : in file: /bsh/commands/which.bsh : cp .getClassSource ( className )
Called from method: which : at Line: 8 : in file: : which ( java .lang .String )
Target exception: java.lang.NullPointerException
java.lang.NullPointerException
Any pointers or help would be appreciated.
Run beanshell with jline.
Download jline jar from http://jline.sourceforge.net/index.html and then you can do:
java -cp jline-1.0.jar:bsh-2.0b4.jar jline.ConsoleRunner bsh.Interpreter
Line editing capability will be provided by jline. I found this hint here.
There are issues running with jline2. First, you'll get:
$ java -cp jline-2.12.jar:bsh-2.0b4.jar jline.ConsoleRunner bsh.Interpreter
Exception in thread "main" java.lang.NoClassDefFoundError: jline/ConsoleRunner
Due to this issue which is fixed. But then, use the new class and you still get:
$ java -cp jline-2.12.jar:bsh-2.0b4.jar jline.console.internal.ConsoleRunner bsh.Interpreter
Exception in thread "main" java.lang.IllegalArgumentException: wrong number of arguments
due to this issue which is not fixed yet.
Use show() command which will trigger showing of value.
bsh % show();
bsh % String s = new String("Hello World");
bsh % s;
<Hello World>
bsh %
It is mentioned in the Useful BeanShell Commands section of the documentation.
Doesn't work for me either
It doesn't fail in my case, but it didn't find it either.
bsh % which(java.lang.String);
Start ClassPath Mapping
Mapping: Archive: file:/Users/me/beanshell/jline-1.0.jar
Mapping: Archive: file:/Users/me/beanshell/bsh-2.0b4.jar
Mapping: Archive: file:/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar
End ClassPath Mapping
null
bsh %

Setting up jdk for ruboto - error

I'm following this tutorial here for setting up Ruboto: http://rubylearning.com/blog/ruboto-quick-start/
I got an error setting up system environment variables in my command line in the JDK step. This is the code I typed in and error received:
$ path=%path%;c:"Program Files"\Java\jdk1.7.0_45\bin;
> classpath=%classpath%;.;
> JAVA_HOME=c:\"Program Files"\Java\jdk1.7.0_45
sh.exe": c:"Program: command not found
Any ideas on what is wrong?
You should surround the whole long pathes with quotes, e. g. :
path=%path%;"c:Program Files\Java\jdk1.7.0_45\bin"
Hope it helps.

Categories

Resources