:: simple-jndi and relative path to config doesn'T work - java

My setting:
Environment
Ubuntu Linux 12.04 LTS
Eclipse Helios
GWT 2.4
Maven 2
simple-jndi
Project
dialoguemaps-domain (Java project folder)
-> src/main/resources/jndi.properties (simple-jndi configuration)
-> config/dialoguemaps.properties (data source configuration)
My problem:
If i use an absolute path in my jndi.properties file - it work's fine:
org.osjava.sj.root=/home/arno/.workspaces/dialoguemaps-trunk/dialoguemaps-domain/config/
But if i use a relative path it doesn't work:
org.osjava.sj.root=config/
I have to use an relative path, but how - what is the problem?
Thank you!

The problem is likely that your relative path isn't relative to what you think it is.
You don't show your error message, but it may contain the absolute path that simple-jndi was trying to resolve.
I think that you're going to have to determine what the absolute path really is, and configure that.

I know its 7 years past since the question is asked but I'm gonna answer it because I also had problem with configuration similar like yours. The best way to deal it it is to put a "." (dot) before "config". Something like:
org.osjava.sj.root=./config/
Console would alert you that it was unable to load class and then would write a path that it tried to load class something like:
[ERROR] ... Unable to load: C:\Users\name.surname\Desktop\appdirectory1\appdirectory2\appdirectory3\.\config
Then you just have to put a directories that are missing. For example I put:
#org.osjava.sj.root=./src/main/resources
and it works just fine.

Related

Error runnning JavaDoc: Cannot generate JavaDoc, jdk path is not specified or invalid

I am trying to generate a JavaDoc in intellij idea and i cannot fix the error.
I'v tried to fix it by add a new path to (Documentation Paths <- SDKs <- Project Structure <- File) but didn't work.
I set the path into jbr folder but
you can check the selected JDK path in your Project Structure popup:
[File->Project Structure->Platform Settings->SDKs]
and specify required path
I had the same issue.
I changed my folder names (they weren't in English), then the path was ok.
I think it applies to special characters as well.

Java getResource is in wrong path

I hope someone can help me here, becouse I'm fighting with a problem for some time. In my main class I use this command:
System.out.println(getClass().getClassLoader().getResource("org"));
The problem I've got is that it returns:
file:/E:/Tmp/ExamplePr/PROJEKT/proj/build/classes/java/main/org
instead of:
file:/E:/Tmp/ExamplePr/PROJEKT/proj/build/resources/java/main/org
The problem is that it goes into classes directory instead of resources dir. As a result I can't have access to my .fxml files I need. I'm using gradle for build and currently working with JavaFX. I've tried something like:
System.out.println(getClass().getClassLoader().getResource("/resources/java/main/org"));
But I just got null :(
Do you know any method to force him to use absolute path or to look for resources in resource filder or even use something like to use "../" from linux to go up. I dodn;t find any of this
The root of your resources tree is defined by the classloader (as described in the JavaDoc). You can define the root by explicitely setting it in your classpath or preferably by using a build tool like maven and following the conventions set and used by the tool. For maven projects the root would usually be at main/java/resources.
getResource will always return the first match in the class path. So if you specify E:/Tmp/ExamplePr/PROJEKT/proj/build/resources/java/main before E:/Tmp/ExamplePr/PROJEKT/proj/build/classes/java/main in your classpath, you will get what you want.
That said, the resources are usually meant to be copied with the classes, and sometimes both are packed in a jar file, so you shouldn't worry about it.
With JavaFX use FXMLLoader;
FXMLLoader.load(new URL(getClass().getResource("/fxml/myfxml.fxml").toExternalForm()));
Make sure to pass the platform appropriate separator and use a relative path.

Ressources can't be found in maven build

I wanted to migrate my local prototype to a maven build and start getting productive. But unfortunately when calling
loader.setLocation(getClass().getResource("views/TaskWindow.fxml"));
On runtime it seems that maven doenst find the ressource xmls.
I tryed "TaksWindow.xml", "../views/TaksWindow.xml" "views/TaskWindow.xml" and "/views/TaksWindow.xml" but somehow it always gives me "no location set" error.
My project structure looks like this:
Any ideas why?
The path you specified is a relative path. Which means the classloader will look for a views folder at the location of the class (i. e. its package). You propably want to use an absolute path.
Try the following code, notice the leading /.
getClass().getResource("/views/TaskWindow.fxml")
For more information, see this answer.

Issue with org.apache.commons.io.FileUtils and Unix absolute/relative path

I am facing issue with absolute/relative path and org.apache.commons.io.FileUtils on Unix box.
Issue is:-
I am using cleanDirectory(..) and copyDirectory(..) of FileUtils. It works fine if I use absolute path /userName/data/feeds but gives IllegalArgumentException when I use paths like /data/feeds and data/feeds.
Please suggest any probable solution. I don't want to use absolute path in my code!!!
Waiting for comments....
/data/feeds is an absolute path too. If the file path starts with an / then it means that it starts from the root directory.
data/feeds probably does not work because you execute Java in a different directory than /userName, probably you start it from /home/userName ?

JPL/SWI Prolog configuration failure

I'm configuring the JPL right now, and wanna work with swi-prolog using java.
I downloaded the newest stable version of SWI-Prolog, which is 6.2.0, and installed in D:\swipl
First, I added the following path to the PATH virable: D:\swipl\bin, which should include all dll files needed.
Then, I added the following path to the CLASSPATH virable: D:swipl\lib\jpl.jar, which should be the jar file needed.
When I tried to run the versions example provided, I got the following error:
Exception in thread "main" java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I
at jpl.fli.Prolog.thread_self(Native Method)
at jpl.Query.open(Query.java:286)
at jpl.Util.textToTerm(Util.java:162)
at jpl.Query.Query1(Query.java:183)
at jpl.Query.<init>(Query.java:176)
at Versions.main(Versions.java:11)
After searching online, I found that many people just get java.lang.UnsatisfiedLinkError: no jpl in java.library.path which is because of the setting for the PATH variable, rather than the error I get here: java.lang.UnsatisfiedLinkError: jpl.fli.Prolog.thread_self()I (and yes, there is a "I" at the end of the line).
Has anyone gotten this error before? I've tried several previous version of SWI-Prolog, but also got other kinds of errors. I'm using Eclipse IDE for Java development -- have I missed anything?
I've sent the problem to the official mailing list (swi-prolog#lists.iai.uni-bonn.de) provided by swi-prolog.org, and luckily someone helped me to prove that there are some problems in the version 6.2.0. We then both tried the version 6.0.2, and it works perfectly. He mentioned that (and I noticed that) there is no swipl.dll in the bin folder of the version 6.2.0, which MAY causes the issue.
I've already reported the issue to the staff via Email, and at least for now, I suggest that people who want to configure JPL should download the version 6.0.2. Three things to remember:
add a new variable SWI_HOME_DIR under system variables in environment variables, and set the path to the place where you installed the SWI-Prolog (Mine is D:\swipl);
Add the path %SWI_HOME_DIR%\bin to your PATH variable, rather than use something like "D:\swipl\bin". (Otherwise [FATAL ERROR: Could not find system resources] will occur)
Add the path %SWI_HOME_DIR%\lib\jpl.jar to your PATH variable, rather than use something like "D:\swipl\lib\jpl.jar". (Otherwise [FATAL ERROR: Could not find system resources] will occur)
If you are using Eclipse for Java development, it seems that you DO NOT need to configure in your IDE. As long as you follow the 3 steps above and add the correct jar file as an external library, it should be fine.
I'm not sure whether the temporary solution works for everyone, but definitely, everyone who has the issue should try this method first. As long as the issue in the version 6.2.0 has been figured out, I'll add some comments here.
BTW, as far as I know, until now, people who have the issue are using 32-bit Windows.
Try adding your path to java.library.path via Run > Run Configuration > [project name] and add the following under "VM Arguments" tab.
-Djava.library.path="D:\swipl\bin;."
Furthermore, under the "Environment" tab, add the following:
VARIABLE: PATH
VALUE: D:\swipl\bin;${env_var:PATH}
After that, go to Project > Properties > Java Build Path, select "Libraries" tab.
Click "Add External JARS.." and find your jpl.jar.
Great Great Great, second answer is the solution
create SWI_HOME_DIR variable to set the swi prolog instalation directory
SWI_HOME_DIR ------- C:\Program Files\swipl
set PATH to point to the library and bin like this
PATH ------ %SWI_HOME_DIR%\bin;%SWI_HOME_DIR%\lib\jpl.jar
This fix my problem "Exception in thread "main" java.lang.UnsatisfiedLinkError: no jpl in java.library.path windows" it is a little bit rare but it works find.
I had the same problem. In addition to set the PATH, you need to verify if the installed SWI program has the same architecture (32 or 64) of your JVM.

Categories

Resources