Hot questions for Using Ubuntu in python

Question:

I've written a launcher for Minecraft 1.12.2 in Python, which just prepares a command and runs it using subprocess.

This is the command formed on Linux Ubuntu:

#!/usr/bin/env bash

java -Xmx4G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -Djava.library.path=/tmp/tmp2dl6pidh -cp /home/kuba/Desktop/launch/package/libraries/org/apache/maven/maven-artifact/3.5.3/maven-artifact-3.5.3.jar:/home/kuba/Desktop/launch/package/libraries/org/apache/httpcomponents/httpcore/4.3.2/httpcore-4.3.2.jar:/home/kuba/Desktop/launch/package/libraries/org/apache/httpcomponents/httpclient/4.3.3/httpclient-4.3.3.jar:/home/kuba/Desktop/launch/package/libraries/org/apache/logging/log4j/log4j-core/2.8.1/log4j-core-2.8.1.jar:/home/kuba/Desktop/launch/package/libraries/org/apache/logging/log4j/log4j-api/2.8.1/log4j-api-2.8.1.jar:/home/kuba/Desktop/launch/package/libraries/org/apache/commons/commons-compress/1.8.1/commons-compress-1.8.1.jar:/home/kuba/Desktop/launch/package/libraries/org/apache/commons/commons-lang3/3.5/commons-lang3-3.5.jar:/home/kuba/Desktop/launch/package/libraries/org/lwjgl/lwjgl/lwjgl_util/2.9.4-nightly-20150209/lwjgl_util-2.9.4-nightly-20150209.jar:/home/kuba/Desktop/launch/package/libraries/org/lwjgl/lwjgl/lwjgl-platform/2.9.4-nightly-20150209/lwjgl-platform-2.9.4-nightly-20150209-natives-linux.jar:/home/kuba/Desktop/launch/package/libraries/org/lwjgl/lwjgl/lwjgl/2.9.4-nightly-20150209/lwjgl-2.9.4-nightly-20150209.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-xml_2.11/1.0.2/scala-xml_2.11-1.0.2.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-compiler/2.11.1/scala-compiler-2.11.1.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-reflect/2.11.1/scala-reflect-2.11.1.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-swing_2.11/1.0.1/scala-swing_2.11-1.0.1.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-parser-combinators_2.11/1.0.1/scala-parser-combinators_2.11-1.0.1.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-actors-migration_2.11/1.1.0/scala-actors-migration_2.11-1.1.0.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/scala-library/2.11.1/scala-library-2.11.1.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/plugins/scala-continuations-plugin_2.11.1/1.0.2/scala-continuations-plugin_2.11.1-1.0.2.jar:/home/kuba/Desktop/launch/package/libraries/org/scala-lang/plugins/scala-continuations-library_2.11/1.0.2/scala-continuations-library_2.11-1.0.2.jar:/home/kuba/Desktop/launch/package/libraries/org/ow2/asm/asm-all/5.2/asm-all-5.2.jar:/home/kuba/Desktop/launch/package/libraries/it/unimi/dsi/fastutil/7.1.0/fastutil-7.1.0.jar:/home/kuba/Desktop/launch/package/libraries/commons-codec/commons-codec/1.10/commons-codec-1.10.jar:/home/kuba/Desktop/launch/package/libraries/oshi-project/oshi-core/1.1/oshi-core-1.1.jar:/home/kuba/Desktop/launch/package/libraries/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar:/home/kuba/Desktop/launch/package/libraries/commons-io/commons-io/2.5/commons-io-2.5.jar:/home/kuba/Desktop/launch/package/libraries/net/sf/jopt-simple/jopt-simple/5.0.3/jopt-simple-5.0.3.jar:/home/kuba/Desktop/launch/package/libraries/net/sf/trove4j/trove4j/3.0.3/trove4j-3.0.3.jar:/home/kuba/Desktop/launch/package/libraries/net/java/jinput/jinput/2.0.5/jinput-2.0.5.jar:/home/kuba/Desktop/launch/package/libraries/net/java/jinput/jinput-platform/2.0.5/jinput-platform-2.0.5-natives-linux.jar:/home/kuba/Desktop/launch/package/libraries/net/java/dev/jna/platform/3.4.0/platform-3.4.0.jar:/home/kuba/Desktop/launch/package/libraries/net/java/dev/jna/jna/4.4.0/jna-4.4.0.jar:/home/kuba/Desktop/launch/package/libraries/net/java/jutils/jutils/1.0.0/jutils-1.0.0.jar:/home/kuba/Desktop/launch/package/libraries/net/minecraftforge/forge/1.12.2-14.23.4.2705/forge-1.12.2-14.23.4.2705.jar:/home/kuba/Desktop/launch/package/libraries/net/minecraft/launchwrapper/1.12/launchwrapper-1.12.jar:/home/kuba/Desktop/launch/package/libraries/lzma/lzma/0.0.1/lzma-0.0.1.jar:/home/kuba/Desktop/launch/package/libraries/io/netty/netty-all/4.1.9.Final/netty-all-4.1.9.Final.jar:/home/kuba/Desktop/launch/package/libraries/java3d/vecmath/1.5.2/vecmath-1.5.2.jar:/home/kuba/Desktop/launch/package/libraries/com/google/guava/guava/21.0/guava-21.0.jar:/home/kuba/Desktop/launch/package/libraries/com/google/code/gson/gson/2.8.0/gson-2.8.0.jar:/home/kuba/Desktop/launch/package/libraries/com/paulscode/codecwav/20101023/codecwav-20101023.jar:/home/kuba/Desktop/launch/package/libraries/com/paulscode/soundsystem/20120107/soundsystem-20120107.jar:/home/kuba/Desktop/launch/package/libraries/com/paulscode/librarylwjglopenal/20100824/librarylwjglopenal-20100824.jar:/home/kuba/Desktop/launch/package/libraries/com/paulscode/libraryjavasound/20101123/libraryjavasound-20101123.jar:/home/kuba/Desktop/launch/package/libraries/com/paulscode/codecjorbis/20101023/codecjorbis-20101023.jar:/home/kuba/Desktop/launch/package/libraries/com/typesafe/config/1.2.1/config-1.2.1.jar:/home/kuba/Desktop/launch/package/libraries/com/typesafe/akka/akka-actor_2.11/2.3.3/akka-actor_2.11-2.3.3.jar:/home/kuba/Desktop/launch/package/libraries/com/ibm/icu/icu4j-core-mojang/51.2/icu4j-core-mojang-51.2.jar:/home/kuba/Desktop/launch/package/libraries/com/mojang/authlib/1.5.25/authlib-1.5.25.jar:/home/kuba/Desktop/launch/package/libraries/com/mojang/text2speech/1.10.3/text2speech-1.10.3-natives-linux.jar:/home/kuba/Desktop/launch/package/libraries/com/mojang/text2speech/1.10.3/text2speech-1.10.3.jar:/home/kuba/Desktop/launch/package/libraries/com/mojang/patchy/1.1/patchy-1.1.jar:/home/kuba/Desktop/launch/package/libraries/com/mojang/realms/1.10.22/realms-1.10.22.jar:/home/kuba/Desktop/launch/package/libraries/jline/jline/2.13/jline-2.13.jar:/home/kuba/Desktop/launch/package/versions/1.12.2/1.12.2.jar net.minecraft.launchwrapper.Launch --username kuba --version 1.12.2 --gameDir /home/kuba/Desktop/launch/package --assetsDir /home/kuba/Desktop/launch/package/assets --assetIndex 1.12 --uuid c8db861e4ea74ebba869459e68de5e15 --accessToken 6cf19a22fac84ebfa62ba697b899bd68 --userType offline --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker --versionType Forge

This is the command formed on Windows 10 Home:

@echo off

java -Xmx4G -XX:+UnlockExperimentalVMOptions -XX:+UseG1GC -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -Djava.library.path=C:\Users\kubac\AppData\Local\Temp\tmpsmseu5hx -cp C:\Users\kubac\Desktop\launch\package\libraries\com\google\code\gson\gson\2.8.0\gson-2.8.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\google\guava\guava\21.0\guava-21.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\ibm\icu\icu4j-core-mojang\51.2\icu4j-core-mojang-51.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\mojang\authlib\1.5.25\authlib-1.5.25.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\mojang\patchy\1.1\patchy-1.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\mojang\realms\1.10.22\realms-1.10.22.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\mojang\text2speech\1.10.3\text2speech-1.10.3-natives-windows.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\mojang\text2speech\1.10.3\text2speech-1.10.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\paulscode\codecjorbis\20101023\codecjorbis-20101023.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\paulscode\codecwav\20101023\codecwav-20101023.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\paulscode\libraryjavasound\20101123\libraryjavasound-20101123.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\paulscode\librarylwjglopenal\20100824\librarylwjglopenal-20100824.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\paulscode\soundsystem\20120107\soundsystem-20120107.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\typesafe\akka\akka-actor_2.11\2.3.3\akka-actor_2.11-2.3.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\com\typesafe\config\1.2.1\config-1.2.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\commons-codec\commons-codec\1.10\commons-codec-1.10.jar:C:\Users\kubac\Desktop\launch\package\libraries\commons-io\commons-io\2.5\commons-io-2.5.jar:C:\Users\kubac\Desktop\launch\package\libraries\commons-logging\commons-logging\1.1.3\commons-logging-1.1.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\io\netty\netty-all\4.1.9.Final\netty-all-4.1.9.Final.jar:C:\Users\kubac\Desktop\launch\package\libraries\it\unimi\dsi\fastutil\7.1.0\fastutil-7.1.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\java3d\vecmath\1.5.2\vecmath-1.5.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\jline\jline\2.13\jline-2.13.jar:C:\Users\kubac\Desktop\launch\package\libraries\lzma\lzma\0.0.1\lzma-0.0.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\java\dev\jna\jna\4.4.0\jna-4.4.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\java\dev\jna\platform\3.4.0\platform-3.4.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\java\jinput\jinput\2.0.5\jinput-2.0.5.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\java\jinput\jinput-platform\2.0.5\jinput-platform-2.0.5-natives-windows.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\java\jutils\jutils\1.0.0\jutils-1.0.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\minecraft\launchwrapper\1.12\launchwrapper-1.12.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\minecraftforge\forge\1.12.2-14.23.4.2705\forge-1.12.2-14.23.4.2705.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\sf\jopt-simple\jopt-simple\5.0.3\jopt-simple-5.0.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\net\sf\trove4j\trove4j\3.0.3\trove4j-3.0.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\commons\commons-compress\1.8.1\commons-compress-1.8.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\commons\commons-lang3\3.5\commons-lang3-3.5.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\httpcomponents\httpclient\4.3.3\httpclient-4.3.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\httpcomponents\httpcore\4.3.2\httpcore-4.3.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\logging\log4j\log4j-api\2.8.1\log4j-api-2.8.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\logging\log4j\log4j-core\2.8.1\log4j-core-2.8.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\apache\maven\maven-artifact\3.5.3\maven-artifact-3.5.3.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\lwjgl\lwjgl\lwjgl\2.9.4-nightly-20150209\lwjgl-2.9.4-nightly-20150209.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\lwjgl\lwjgl\lwjgl-platform\2.9.4-nightly-20150209\lwjgl-platform-2.9.4-nightly-20150209-natives-windows.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\lwjgl\lwjgl\lwjgl_util\2.9.4-nightly-20150209\lwjgl_util-2.9.4-nightly-20150209.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\ow2\asm\asm-all\5.2\asm-all-5.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\plugins\scala-continuations-library_2.11\1.0.2\scala-continuations-library_2.11-1.0.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\plugins\scala-continuations-plugin_2.11.1\1.0.2\scala-continuations-plugin_2.11.1-1.0.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-actors-migration_2.11\1.1.0\scala-actors-migration_2.11-1.1.0.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-compiler\2.11.1\scala-compiler-2.11.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-library\2.11.1\scala-library-2.11.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-parser-combinators_2.11\1.0.1\scala-parser-combinators_2.11-1.0.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-reflect\2.11.1\scala-reflect-2.11.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-swing_2.11\1.0.1\scala-swing_2.11-1.0.1.jar:C:\Users\kubac\Desktop\launch\package\libraries\org\scala-lang\scala-xml_2.11\1.0.2\scala-xml_2.11-1.0.2.jar:C:\Users\kubac\Desktop\launch\package\libraries\oshi-project\oshi-core\1.1\oshi-core-1.1.jar:C:\Users\kubac\Desktop\launch\package\versions\1.12.2\1.12.2.jar net.minecraft.launchwrapper.Launch --username kuba --version 1.12.2 --gameDir C:\Users\kubac\Desktop\launch\package --assetsDir C:\Users\kubac\Desktop\launch\package\assets --assetIndex 1.12 --uuid 1e12c9641d68419c8e0ef3c43adc9678 --accessToken c270917a4aa44267859663b52ebdf07f --userType offline --tweakClass net.minecraftforge.fml.common.launcher.FMLTweaker --versionType Forge

PROBLEM: Ubuntu version executes perfectly, without any complain, but Windows version says:

Error: Could not find or load main class net.minecraft.launchwrapper.Launch

and it does not start at all.

As u see Ubuntu and Windows commands are almost identical.

The minecraft installation (used on both Ubuntu and Windows) that I'm trying to start, comes from Windows (generated by official launcher, forge is installed, I only replace libraries marked as natives because they are platform dependent), and it can be started using official launcher on both platforms without any problems, so I assume that there is no issue with missing or corrupted minecraft files. Moreover I was able to start it using my custom launcher but only on Ubuntu, as I wrote above.

Do u guys have any suggestions on what am I doing wrong?

PS I've tried to start Vanilla Minecraft using my custom launcher and the issue is exactly the same, it works on Ubuntu, but fails on Windows with the same error (ofc it mentions vanilla class instead)

EDIT I do not provide the Python code as it is long, and it just extracts natives to a temporary folder and forms the command to launch minecraft, which could be just written by hand and pasted into a script and executed.


Answer:

Ok, actually, on Windows the classpath separator is ; not : Replacing separator fixes this issue

Question:

I have to calling python script in java project.I dont use jython because in script i using todoist-api. I tried use this:

try {
    String cmd = "/home/kiryushin/projects/python/stm/venv/lib/stmtest1.py";
    Process p = Runtime.getRuntime().exec(cmd);
}
catch (IOException e){e.printStackTrace();} 

I get

" java.io.IOException: Cannot run program "/home/kiryushin/projects/python/stm/venv/lib/stmtest1.py": error=13, Permisson denied"

I try change permission with chmod -r 777, and other commands but i get this error again.

Ubuntu 18.04 lts. JDK 10. Intelij idea community edition.


Answer:

Try with :

First manually check with sudo permission.

And modify:

String cmd = "sudo python /home/kiryushin/projects/python/stm/venv/lib/stmtest1.py"

Question:

I was using pycharm on Ubuntu fine, until I restarted the system to make some updates. Then I cannot start Pycharm anymore. I tried to start from terminal and it gives error "Unrecognized VMoption 'MaxPermSize=350m'".

I suppose this is something to do with the Java...? I have read that the latest version of Java does not work for Pycharm or something before... maybe it got "updated" automatically to the latest version when I restarted the system? Please advise me how I can start my Pycharm... thanks


Answer:

This link (https://askubuntu.com/questions/624199/problem-with-java-while-trying-to-run-pycharm-community-4-5) says to:

Open the file pycharm64.vmoptions

nano /opt/pycharm-community-4.5/bin/pycharm64.vmoptions

and add a # at the beginning of the line

# -XX:MaxPermSize=350m

Open the file pycharm.vmoptions

nano /opt/pycharm-community-4.5/bin/pycharm.vmoptions

and add a # at the beginning of the line

# -XX:MaxPermSize=250m

Question:

I am using several programs written in JAVA, Pyhton, and Perl, invoking them via command line.

I am often performing the same task on multiple files and I would like use a

for

loop instead. However, there are some program options that should be adjusted for each file. I thought to store the strings describing the options in text files and copy them into the flag corresponding to the option. For example for a python program:

python <Prog_X.py> input -option1 xxxx -option2 <here I want to copy content of File.txt> -out

I am not quite sure how to do that. Maybe it is a basic thing but I cannot find a way around it.

Any idea how could I do that?


Answer:

If the option file contain only a single line you could do

python <Prog_X.py> input -option1 xxxx -option2 $(cat option.txt) -out