• Post Reply Bookmark Topic Watch Topic
  • New Topic

Need help understanding things that I think should already know.  RSS feed

 
Rick lange
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear with me. I have been programming with Java as a hobby for about a year now, and I am pretty well versed on concepts such as OOP, Java syntax and using libraries, writing and running programs in Eclipse, etc. I can write a 2D side-scrolling with objectives in a day. All my knowledge comes the internet, so you could say that it is a bit selective. I feel in as far as I have come, I missed out some very fundamental concepts that are just now coming to light. I am now trying to try out Slick2D and LWJGL, and I can't seem to get going with this. In Eclipse, in the Run Configurations menu, I am completely lost, so much that I cannot understand the answers I receive when I ask questions. I don't know what the Program arguments/Virtual Machine arguments are, I don't know what the classpath is, I don't know what the source look-up thing is, I don't know what refactoring is, Bootstrap entries, etc, a whole bunch of stuff. For example, I copy and pasted this error message into google:

java.lang.UnsatisfiedLinkError: no jinput-dx8_64 in java.library.path

And will find answers such as:

you should set java.library.path property to point to the directory containing native dlls of JInput. You can do it by adding -Djava.library.path=x (where x is your path) to the command line or to the "VM arguments" field of "Run configurations" dialog in Eclipse.

Or something else like:

Try this:
java -Djava.library.path=lib -jar C:\...\BoxRiders.jar

And in the folder lib, you have to put:
-lwjgl.jar
-native libraries for your environment: jinput-dx8.dll, jinput-raw.dll, lwjgl.dll

And I'm sitting here thinking: "What is this java.library path? X is my path to what? My environment is Eclipse, how can jinput libraries be native if I had to bring them in from the outside?

Needless to say, I'm missing way to much information to be going in this direction. So could somebody please direct me to tutorials, books, etc, anything that will bring me up to speed on these seemingly more technical concepts that I obviously haven't learned yet.
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The java.library.path is similar to the classpath. The classpath tells java where to look for class files, but java.library.path yells java where to look for native libraries. In this context a native library is one that runs natively on the system externally to Java, so a DLL or .so file.

The advice you have been given is accurate. You set java.library.path on the command line using -Djava.library.path=X as a parameter to the java command.

In this case X is the path to the directory that contains the dll or .so files.

In eclipse you configure this argument in the vm-arguments box in the run-configurations dialogue.
 
Rick lange
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Mike J Thompson

Ok, you certainly gave me some of the clarification I was seeking on the specific issue. I understand some things now. So for the VM arguments I have this:
-Djava.library.path=C:\users\derrick\desktop\Slick2DandLWJGL\lwjgl\native\windows\x64 ControllerTest

And now I get this error:

Error: Could not find or load main class ControllerTest

This is my main class, and it is recognized as such within the Run Configurations menu,

Thanks for your help so far. If you know of any resources I could use to study this kind of material please let me know.

EDIT: I have also tried being more specific with the class path as such:

-Djava.library.path=C:\users\derrick\desktop\Slick2DandLWJGL\lwjgl\native\windows\x64 com.derrick.controllertests.ControllerTest
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The solution might be much easier than doing all that.

Have you seen this SO article? http://stackoverflow.com/questions/19344914/getting-java-lang-unsatisfiedlinkerror-no-lwjgl-in-java-library-path
 
Rick lange
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
@Junili Lacar I understand that my ignorance to the concept of native libraries to Eclipse would cause you to direct me to that question, but I actually did configure the build path before any of these other problems. The latest error is the one pertaining to not being able to find or load the main class while it is recognized in the Run Configuration menu.
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick, I'm not making any assumptions about your knowledge or lack thereof, so there's no need to feel like anybody is judging you or anything like that. I was just going off of my own experience with Eclipse in that there's hardly ever a need to go low-level like how you were describing. If you just want to run a class that has a static void main method, then you usually just right click on the class and select "Run as... Java application" -- this will usually create a run configuration for you that you can tweak if you want. Did you do that or did you start by manually creating a Run Configuration?
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BTW, Rick, Welcome to the Ranch!
 
Rick lange
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Junilu, I'm sorry, I really didn't mean to come off as offended by your reply. I wasn't at all, and I appreciate anyone who would take their time to give me pointers. I tried letting Eclipse build me a new Run Configuration and I still get the same problem, it just will not recognize my main class (ControllerTest). I'll try to give some more specifics to my problem.

When I just specify the java.library path in the VM Argument dialog ( -Djava.library.path=C:\users\derrick\desktop\Slick2DandLWJGL\lwjgl\native\windows\x64 ) I get this mess:

Loading: net.java.games.input.DirectAndRawInputEnvironmentPlugin
java.lang.UnsatisfiedLinkError: no jinput-dx8_64 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at net.java.games.input.DirectInputEnvironmentPlugin$1.run(DirectInputEnvironmentPlugin.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.input.DirectInputEnvironmentPlugin.loadLibrary(DirectInputEnvironmentPlugin.java:67)
at net.java.games.input.DirectInputEnvironmentPlugin.<clinit>(DirectInputEnvironmentPlugin.java:109)
at net.java.games.input.DirectAndRawInputEnvironmentPlugin.<init>(DirectAndRawInputEnvironmentPlugin.java:45)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:157)
at com.derrick.controllertests.ControllerTest.main(ControllerTest.java:12)
java.lang.UnsatisfiedLinkError: no jinput-raw_64 in java.library.path
at java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.lang.Runtime.loadLibrary0(Unknown Source)
at java.lang.System.loadLibrary(Unknown Source)
at net.java.games.input.RawInputEnvironmentPlugin$1.run(RawInputEnvironmentPlugin.java:75)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.input.RawInputEnvironmentPlugin.loadLibrary(RawInputEnvironmentPlugin.java:67)
at net.java.games.input.RawInputEnvironmentPlugin.<clinit>(RawInputEnvironmentPlugin.java:109)
at net.java.games.input.DirectAndRawInputEnvironmentPlugin.<init>(DirectAndRawInputEnvironmentPlugin.java:46)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at java.lang.Class.newInstance(Unknown Source)
at net.java.games.input.DefaultControllerEnvironment.getControllers(DefaultControllerEnvironment.java:157)
at com.derrick.controllertests.ControllerTest.main(ControllerTest.java:12)
net.java.games.input.DirectAndRawInputEnvironmentPlugin is not supported


And when I include my classpath after the library path ( -Djava.library.path=C:\users\derrick\desktop\Slick2DandLWJGL\lwjgl\native\windows\x64 com.derrick.controllertests.ControllerTest ) I get this:

Error: Could not find or load main class com.derrick.controllertests.ControllerTest

I noticed other people doing it, but I don't think I'm supposed to specify my classpath after the library path?
 
Junilu Lacar
Sheriff
Posts: 11476
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rick lange wrote:And in the folder lib, you have to put:
-lwjgl.jar
-native libraries for your environment: jinput-dx8.dll, jinput-raw.dll, lwjgl.dll
...
-Djava.library.path=C:\users\derrick\desktop\Slick2DandLWJGL\lwjgl\native\windows\x64 ControllerTest

Is C:\users\derrick\desktop\Slick2DandLWJGL\lwjgl\native\windows\x64 included in your system path? That is, see if that directory is included in the value displayed when you open a command line window and type path. If it's not, try adding this directory to your path environment variable or you could try moving those .DLL files to a directory that is in your system path.
 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are not supposed to specify your classpath in the vm-arguments path. There should be a separate tab in the run-configurations window for the classpath I think.

Is the class you are trying to run written by you, or an example provided with the library?
 
Rick lange
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I really do appreciate the help, and have learned a few things, but I feel it was a mistake on my part to include in this thread the specific issue I was having with Slick2D and LWJGL, because that issue seems to have taken center stage. The theme of this thread was really to be pointed in a direction where I can learn to help myself on concepts pertaining to the issue. For instance, I don't know what a path environment variable is or how I'm supposed to manipulate it. And yet again, when I try to look it up, the explanations are beyond me: "Environment variables hold values related to the current environment, like the Operating System or user sessions." This means nothing to me, I really don't know what to do with this information. Will I find this in a book on Java? Computers for dummies? If I'm told what to do, and I do it, and the specific issue is resolved, then I'm no better then the computer itself in that I'm just following instructions without really knowing why. Being self-taught, my knowledge in this field is quite fragmented, and I blame no one but myself for not being better prepared.

That being said, should I (can I) close this thread and try again or should I roll with it? This is my first time on any Java forum ever, so perhaps I'm doing it all wrong?

But while I'm here:

Junilu, I tried moving the .dll files to to one of the listed directories and updated the build path and still the issue is not resolved, so I put everything back. Do you think that if I spent some time learning how to use Java with the command prompt (as opposed to an IDE) that I might be better serving myself to understand the problem?

Mike, I wrote the class, here is the code:

package com.derrick.controllertest;

import net.java.games.input.Controller;
import net.java.games.input.ControllerEnvironment;

public class ControllerTest {

public static void main(String[] args) {
ControllerEnvironment ce = ControllerEnvironment.getDefaultEnvironment();
Controller[] c = ce.getControllers();
for(int i = 0; i < c.length; i++){
System.out.println(c[i].getName());
}
}

}

 
Mike. J. Thompson
Bartender
Posts: 689
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I do get the sense that you may have jumped in at the deep end and perhaps are becoming a little overwhelmed by lots of different concerns.

Some of the things you're looking at relate to Java, and some of the things are nothing to do with Java specifically.

For example the Classpath is a java concept, but environment variables (and the system PATH variable is one of these) is an operating system concept. Both Windows and Linux/Unix have thus concept.

I think it Kay be best for you to go back to basics somewhat, and playing around with Java on the command line with some very basic programs will help. You need to keep the programs simple so you can be clear how the values you're passing to Java affect the outcome.

Perhaps if you pick a single concept at a time you need help with and we help you with that until you get it. If we keep it to using the command line then you will both see what options are available and not have to worry that eclipse is hiding something.

There will likely be tutorials on the Internet that explain it better, but the PATH variable is a list of directories that the operating system will look in when you ask it to run a program.

For example if you type 'ping' on the command line the operating system will look in all of these directories until it finds ping.exe (on Windows).
 
Rick lange
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mike, you've described my situation perfectly, and your advice is exactly what I was looking for. I need to go back to the basics, one by one filling in my (knowledge) blanks, and starting at the command line sounds like a grand idea. Hopefully I will be able to ask more concise questions in the future. Thanks for your prompt responses, both of you!
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!