Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cant run Shell Script to launch Jar

i have a windows batch script which launches a jar which launches a game written all in Java (its a runescape client). It should work.

The original Batch (WIN):

@echo off
@echo Client Is loading......
@echo -----------------------
java -Xmx1000m -cp .;Theme.jar Gui 0 0 highmem members 32
pause

the Shell file ive made for OS:

#!/bin/sh
echo Your client is loading...
echo --------------------
java -Xmx1000m -cp Theme.jar Gui 0 0 highmem members 32

the error in terminal:

Your Client is loading...
--------------------
Exception in thread "main" java.lang.NoClassDefFoundError: Gui
Caused by: java.lang.ClassNotFoundException: Gui
    at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:247)

How can i fix it or make a shell script that will do the exact as the Batch and actually run?


1 Answers

You didn't convert the shell script correctly. In the Windows version the -cp parameter is .;Theme.jar, so in Linux it should be .:Theme.jar, the path separator ; replaced with :, like this:

java -Xmx1000m -cp .:Theme.jar Gui 0 0 highmem members 32

A ClassNotFoundException in general signals something wrong with the classpath. (The -cp parameter is a shortcut for -classpath).

Judging by the Windows script, Gui is a class name, and the rest are command line arguments passed to the Gui class. The error message tells you it cannot find the Gui class. It must be either in the current directory or the theme.jar. If it's not in any of them then this can't work.

like image 143
janos Avatar answered Dec 02 '25 16:12

janos