how do i run java programs using the terminal to add more ram to the program?

Asked by Brandon

Iv looked around and can't find anything on how to run minecraft or any java program through the terminal.

Question information

Language:
English Edit question
Status:
Answered
For:
Ubuntu gnome-terminal Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
enubuntu (mr.tennents) said :
#1

Hi please try to use this command:
java -jar /path/to/file.jar

Change /path/to/file.jar witht the path of your file before.

Revision history for this message
enubuntu (mr.tennents) said :
#2
Revision history for this message
Brandon (14020kep) said :
#3

iv tried both and they didnt work do you have a more simple way to explain it, im kinda new to usimg the terminal

Revision history for this message
delance (olivier-delance) said :
#4

What's the name of your java file ?

Revision history for this message
Jacobsallan (jacobsallan) said :
#5

The name of the java file is easy: Minecraft.jar .

From http://www.minecraft.net/download.jsp.
(1) It says that the Sun JVM is required. That would be a package with a name like sun-java6-jre. The default jre (Java Runtime Environment) is probably openjdk instead (depending on your Ubuntu version).
(2) Once you have a jre in place, find the path to the java executable. If your system has two JREs you will need the path to run the correct version. If you have only one JRE, then life is easier and you can ignore this step.
(3) Download Mincraft.jar
(4) Use the command line
% ${PATH_TO_JAVA}/java -Xmx1024M -Xms512M -cp Minecraft.jar net.minecraft.LauncherFrame

Revision history for this message
Brandon (14020kep) said :
#6

whats the default path to java?

Revision history for this message
delance (olivier-delance) said :
#7

You can simply use "java".
Else open a terminal and type "which java".

Revision history for this message
Brandon (14020kep) said :
#8

i tried everything the jre location is /urs/bin/java what command do i need to use?

Revision history for this message
Brandon (14020kep) said :
#9

im kinda new at using the terminal

Revision history for this message
Jacobsallan (jacobsallan) said :
#10

Try
% echo $PATH
should respond with a :-separated list of directories and one of these should be /usr/bin. Paste the result as an added comment here in Launchpad.

Try
% java -version
% /usr/bin/java -version
Paste the results as an added comment here in Launchpad.

If your Minecraft.jar is in the current working directory
% /usr/bin/java -Xmx1024M -Xms512M -cp Minecraft.jar net.minecraft.LauncherFrame

If Minecraft.jar is in a different directory, say /home/yourname/foo/mine.
% /usr/bin/java -Xmx1024M -Xms512M -cp /home/yourname/foo/mine/Minecraft.jar net.minecraft.LauncherFrame

For many programs, the -X arguments are not needed. Minecraft is a memory pig. There are two kinds of memory, heap and stack. When running a program, it's best to follow user instructions when setting these. The -cp <path> argument pair is a path to the Java classes you wish to run. In this case, the classes are inside a jar file -- a kind of software bottle. net.minecraft.LauncherFrame is an argument to the Minecraft program.

Revision history for this message
Brandon (14020kep) said :
#11

/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

Revision history for this message
Brandon (14020kep) said :
#12

java version "1.6.0_22"
OpenJDK Runtime Environment (IcedTea6 1.10.2) (6b22-1.10.2-0ubuntu1~11.04.1)
OpenJDK Client VM (build 20.0-b11, mixed mode, sharing)

Revision history for this message
Jacobsallan (jacobsallan) said :
#13

% java -Xmx1024M -Xms512M -cp /home/yourname/foo/mine/Minecraft.jar
should work. The -Xmx1024M is adding more ram to your program. That's 1024 Megabytes of heap space. If you need more, change it to -Xmx1500M. I don't know what the upper limit is.

Can you help with this problem?

Provide an answer of your own, or ask Brandon for more information if necessary.

To post a message you must log in.