Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (523)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (591)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  loading library from jar, classpath...  (Read 2281 times)
0 Members and 1 Guest are viewing this topic.
Offline xRot

Senior Newbie





« Posted 2009-06-12 19:32:46 »

Hi

I'm not new to programming but some things in java I don't understand until know.

I'm programming at Linux Debian Lenny 64Bit.

The first thing: I got the JInput class as .jar file
I createt a class with the code from http://www.java-gaming.org/topics/getting-started-with-jinput/16866/view.html
when i compile the class I got an error.
1  
2  
3  
4  
5  
test.java:5: cannot find symbol
symbol  : class Controller
location: class test
        Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
// and some more...


I know I should place the jinput.jar in the classpath. Can anyone tell me: "How I can compile the class with the jar in the same directory?"

at the moment I compile and run the code with
1  
2  
# javac *.class
# java test
Offline mh114

Junior Devvie





« Reply #1 - Posted 2009-06-13 10:49:18 »

Does this work:
1  
2  
javac -cp .:JARFILE.jar *.java
java -cp .:JARFILE.jar test


That sets the class path to working directory . and the jar JARFILE.jar. Smiley

Offline xRot

Senior Newbie





« Reply #2 - Posted 2009-06-13 11:45:08 »

no Sad

1  
javac -cp .:jinput.jar *.java

same errors

Quote
test.java:5: cannot find symbol
symbol  : class Controller
location: class test
        Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
        ^
test.java:5: cannot find symbol
symbol  : variable ControllerEnvironment
location: class test
        Controller[] ca = ControllerEnvironment.getDefaultEnvironment().getControllers();
                          ^
test.java:14: cannot find symbol
symbol  : class Component
location: class test
            Component[] components = ca.getComponents();
            ^
3 errors

I downloaded the latest JInput Binaries and put them in the directory
Quote
jinput-dx8_64.dll  jinput-dx8.dll  jinput.jar  jinput-raw_64.dll  jinput-raw.dll  jinput-test.jar  jinput-wintab.dll  libjinput-linux64.so  libjinput-linux.so  libjinput-osx.jnilib  test.java
test.java is my class
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline davidc

Senior Devvie


Medals: 5
Projects: 2



« Reply #3 - Posted 2009-06-13 12:57:00 »

Have you got all the required import statements in your .java file? If the classpath wasn't setup correctly (as it may have been when you first compiled) but the imports were, then the errors should have been with the imports and not the variable declaration.
Offline xRot

Senior Newbie





« Reply #4 - Posted 2009-06-13 13:02:13 »

hmm, no

got no imports at the moment Cheesy

which imports I should have?
Offline davidc

Senior Devvie


Medals: 5
Projects: 2



« Reply #5 - Posted 2009-06-13 13:05:23 »

Try this:

import net.java.games.input.*;

Some might frown at having a blanket import statement like that, but it will get things moving in the right direction.
Offline xRot

Senior Newbie





« Reply #6 - Posted 2009-06-13 13:13:20 »

I thought java has a autoload functionality like with other classes Cheesy
Know I understand the hole thing, thank you.

unfortunately I got this Errors while executing
Quote
Loading: net.java.games.input.LinuxEnvironmentPlugin
Failed to load library: no jinput-linux64 in java.library.path
java.lang.UnsatisfiedLinkError: no jinput-linux64 in java.library.path
   at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1698)
   at java.lang.Runtime.loadLibrary0(Runtime.java:840)
   at java.lang.System.loadLibrary(System.java:1047)
   at net.java.games.input.LinuxEnvironmentPlugin$1.run(LinuxEnvironmentPlugin.java:66)
   at java.security.AccessController.doPrivileged(Native Method)
   at net.java.games.input.LinuxEnvironmentPlugin.loadLibrary(LinuxEnvironmentPlugin.java:58)
   at net.java.games.input.LinuxEnvironmentPlugin.<clinit>(LinuxEnvironmentPlugin.java:101)
   at java.lang.Class.forName0(Native Method)
   at java.lang.Class.forName(Class.java:186)
   at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:156)
   at test.main(test.java:6)
net.java.games.input.LinuxEnvironmentPlugin is not supported

Is there a Linux 64Bit Plugin or a workaround for this error?

Tried the Nightly build, same error
Offline davidc

Senior Devvie


Medals: 5
Projects: 2



« Reply #7 - Posted 2009-06-13 13:20:35 »

I thought java has a autoload functionality like with other classes Cheesy

It does for classes in java.lang, but not other packages.

Anyway, it looks like you have the classpath now set correctly, but you may need to download an additional lib. Have you checked the documentation? It may mention that there is a file already downloaded that needs to be put in a specific location (not the classpath). The link to endolf's post you made earlier on has a few points you may have missed.

EDIT: try adding the library path to your java command, eg:

java -Djava.library.path=. classname
Offline xRot

Senior Newbie





« Reply #8 - Posted 2009-06-13 13:39:43 »

thanks

It's working now

1  
java -Djava.library.path=. -cp .:jinput.jar test


Last question the "libjinput-linux64.so" file have to be in the library path, thats right?

Offline davidc

Senior Devvie


Medals: 5
Projects: 2



« Reply #9 - Posted 2009-06-13 13:45:58 »

Correct. In your case the library path and classpath happen to include the same folder. You probably want to keep things separate in future otherwise it will start to get messy, but at least now you can focus on writing some code.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (34 views)
2014-11-22 12:13:56

xFryIx (73 views)
2014-11-13 12:34:49

digdugdiggy (52 views)
2014-11-12 21:11:50

digdugdiggy (46 views)
2014-11-12 21:10:15

digdugdiggy (40 views)
2014-11-12 21:09:33

kovacsa (66 views)
2014-11-07 19:57:14

TehJavaDev (70 views)
2014-11-03 22:04:50

BurntPizza (68 views)
2014-11-03 18:54:52

moogie (83 views)
2014-11-03 06:22:04

CopyableCougar4 (82 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!