3

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?

2
  • Why are you including the current folder to the class path in your batch but not in your shell script? I speak of -cp .;Theme.jar in batch but -cp Theme.jar in shell file. Commented Mar 14, 2014 at 6:22
  • well if i do, i get this error pastie.org/8918011 (its too long to post) Commented Mar 14, 2014 at 6:23

3 Answers 3

1

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.

Sign up to request clarification or add additional context in comments.

16 Comments

@Nicco is there a Gui.class file in the directory where you are running this? Or if you do jar tf Theme.jar | grep Gui.class what do you get?
arent Gui 0 0 highmem members 32 just variables? I didnt write the original Batch, i only know it works on Windows.. How shall i include your solution?
@Nicco 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. You didn't answer my questions in my previous comment.
i got this btw pastie.org/8918043 its only half due to copy limits
@Nicco this can't be the output of what I asked. I repeat: is there a Gui.class file in the directory where you are running this? Or if you do jar tf Theme.jar | grep Gui.class what do you get?
|
0

java.lang.ClassNotFoundException

I think there might be two reason:

  1. The jar file which you are including while running the java program is not included into the jar file which you have created for shell script.

  2. You have not defined Main-Class in manifest.mf file while you created your jar file.

Comments

0

Try using this,

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

as ':' is the classpath seperator for Unix environments while ';' is for Windows.

10 Comments

Try putting no space between .: and Theme.jar, I mean try using .:Theme.jar
@Nicco maybe because of the accidental space character in there after :. Make sure there is no space in .:Theme.jar.
yeah, i did remove that :( still didnt work and orig error. This is weird
on windows do this java -verbose -Xmx1000m -cp Theme.jar Gui 0 0 highmem members 32 this will print all classes being loaded and the src class (if file is not in jars) or jar file names. maybe you have not copied something from windows to linux/iOs. also run chmod 777 * on the dir in linux so all users can load all files.
Try this, java -Xmx1000m -cp Theme.jar:./ Gui 0 0 highmem members 32
|