You are not logged in.

#1 2012-02-01 05:00:22

CPUnltd
Member
From: Milwaukee, WI
Registered: 2009-12-05
Posts: 483
Website

[SOLVED!!!]Need help getting internet cafe software to execute...

Already submitted to AUR: https://aur.archlinux.org/packages.php?ID=56282

I'm building a PKGBUID for a program called Cafe Pilot.  I'm using it for the computer lab in my shop and could use some help getting it to execute properly.  I'm pretty sure the PKGBUILD is good, because I can build and install just fine, but I get the error message below when I try to execute via CLI:

Caused by: java.lang.ClassNotFoundException: CafePilot_Server.jar
	at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
	at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
	at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
Could not find the main class: CafePilot_Server.jar. Program will exit.

not quite sure what this means... do I need to use JRE, or can i get away with openjdk on this?  ANY input would help... working on the companion client package, but wanted to get the server out of the way first so I can streamline the creation of the client's PKGBUILD...  Thanks in advance!


SOLUTION: editing of PKGBUILD and .sh file as posted below
https://bbs.archlinux.org/viewtopic.php … 4#p1051824

Last edited by CPUnltd (2012-02-02 23:42:05)


Help grow the dev population... have your tech trained and certified!

Offline

#2 2012-02-02 19:53:45

Wey
Member
Registered: 2011-04-22
Posts: 217

Re: [SOLVED!!!]Need help getting internet cafe software to execute...

This works for me:

Drop the -classpath in your sh:

#!/bin/bash

cd /opt/CafePilot_Server
java -jar CafePilot_Server.jar

Add the lib directory from the zip to your package(), like

cp -r "$srcdir"/lib/ "$pkgdir"/opt/$pkgname1/

(or some equivalent install-invocation).

Also, this should suffice:

depends=('java-runtime')

P. s.: Actually, the first fix is against the error message you posted above. After that, you will run into the error you posted there https://bbs.archlinux.org/viewtopic.php?id=133639, which then should be solved with the second fix.

Last edited by Wey (2012-02-02 20:26:22)

Offline

#3 2012-02-02 21:17:29

CPUnltd
Member
From: Milwaukee, WI
Registered: 2009-12-05
Posts: 483
Website

Re: [SOLVED!!!]Need help getting internet cafe software to execute...

I thought I'd posted something about this PKGBUILD around here before, but wasn't sure when I posted this one.  They are not exactly the same issue, so I should be good on the forum rules... my current sh looks like this:

#!/bin/bash

cd /opt/CafePilot_Server
'/usr/lib/jvm/java-6-openjdk/bin/java' -classpath -jar CafePilot_Server.jar

I'm still pretty new to dealing with java in PKGBUILDs, so expect noob questions.  I'm sure there's a way to make this more universal (the "/java-6-openjdk/" part about this is what catches my attention as something that should be more universal... what's a good way to go about altering this?


Help grow the dev population... have your tech trained and certified!

Offline

#4 2012-02-02 22:31:30

Wey
Member
Registered: 2011-04-22
Posts: 217

Re: [SOLVED!!!]Need help getting internet cafe software to execute...

1. The usage of the -classpath switch is incorrect. Per manpage, you invoke it like "-classpath <somepath>". So when you call

java -classpath -jar CafePilot_Server.jar

java 6 will throw an "NoClassDefFoundError: CafePilot_Server/jar". That means, java failed to find the class "jar" in the package "CafePilot_Server", which is not exactly what you intended to do (in java packages are delimited by dots like com.mypackage.MyClass, which would go into a file hierarchy like ./com/mypackage/MyClass.class). java 7 will give you the more shorter message: "Could not find or load main class CafePilot_Server.jar"

So in short, the -classpath flag eats your -jar flag. The easiest way around this is, to omit "-classpath", which will result the classpath defaulting to the current directory, or to call "-classpath /opt/CafePilot_Server/".

2. About the '/usr/lib/jvm/java-6-openjdk/bin/java' part: Is there a specific reason to not call the "java" command directly? On a java 7 install:

$file `which java`
/usr/bin/java: symbolic link to `/usr/lib/jvm/java-7-openjdk/jre/bin/java'

And on a java 6 one:

$file `which java`
/usr/bin/java: symbolic link to `/usr/lib/jvm/java-6-openjdk/bin/java`

So i would promote one of the following options:

a)

#!/bin/bash
cd /opt/CafePilot_Server
java -jar CafePilot_Server.jar

b)

#!/bin/bash
java -classpath /opt/CafePilot_Server/ -jar /opt/CafePilot_Server/CafePilot_Server.jar

I do not really have an idea of what the program is supposed to do, but as far as i can see, b) has the advantage, that you do not need to call it as root, since the program will write some logs to the current directory. So when you call a) as a normal user, you will get an Permission denied error, because the programm could not write its derby.log to /opt/CafePilot_Server/, whereas for b) you could call it from your home directory, and you will get the log right there.

Both options assume, that the lib/ directory is installed as mentioned in my previous post.

Last edited by Wey (2012-02-02 22:37:39)

Offline

#5 2012-02-02 23:22:13

CPUnltd
Member
From: Milwaukee, WI
Registered: 2009-12-05
Posts: 483
Website

Re: [SOLVED!!!]Need help getting internet cafe software to execute...

I was following a suggested method of execution (where the suggestion came from, I do not recall... I was researching while I was working on the PKGBUILD and did not keep track of reference sources, something I should change)... 

I took your advice and added the cp line to the end of the PKGBUILD as well as the long method of execution in the .sh file.  Just built it and it loaded just fine!  Will be labeling solved, uploading the newest version of the build and working on the client for this software!  Thanks again!!!


Help grow the dev population... have your tech trained and certified!

Offline

Board footer

Powered by FluxBB