Tagged Questions
119
votes
14answers
102k views
How to get the path of a running jar file?
My code runs inside a jar file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is.
So, if foo.jar is in C:\FOO\, I want to get that path no matter what my current ...
94
votes
21answers
306k views
Eclipse - no Java (JRE) / (JDK) … no virtual machine
I am trying to get Eclipse Galileo to re-run on my computer - i have run it before with no problems but now i keep getting this error:
A java Runtime Environment (JRE) or Java Development kit ...
78
votes
13answers
62k views
How to construct a relative path in Java from two absolute paths (or URLs)?
Given two absolue paths, e.g.
/var/data/stuff/xyz.dat
/var/data
How can one create a relative path that uses the second path as its base? In the example above, the result should be: ./stuff/xyz.dat
66
votes
6answers
14k views
Combine paths in Java
Is there a Java equivalent for System.IO.Path.Combine() in C#/.NET? Or any code to accomplish this?
This static method combines one or more strings into a path.
39
votes
10answers
95k views
How to add native library to “java.library.path” with Eclipse launch (instead of overriding it)
I got a native library that needs to be added to java.library.path. With JVM argument -Djava.library.path=path... I can set the path as I want.
My problem is that my other library (pentaho reporting) ...
34
votes
4answers
22k views
Does Java have a path joining method? [duplicate]
Exact Duplicate:
combine paths in java
I would like to know if there is such a method in Java. Take this snippet as example :
// this will output a/b
System.out.println(path_join("a","b"));
// a/b
...
33
votes
4answers
5k views
Java 7: Path vs File
For new applications written in Java 7, is there any reason to use a java.io.File object any more or can we consider it deprecated?
I believe a java.nio.file.Path can do everything a java.io.File ...
27
votes
8answers
59k views
How to get a path to a resource in a Java JAR file
I am trying to get a path to a Resource but I have had no luck.
This works (both in IDE and with the JAR) but this way I can't get a path to a file, only the file contents:
ClassLoader classLoader ...
23
votes
4answers
20k views
Create whole path automatically when writing to a new file
I want to write a new file with the FileWriter. I use it like this:
FileWriter newJsp = new FileWriter("C:\\user\Desktop\dir1\dir2\filename.txt");
Now dir1 and dir2 currently don't exist. I want ...
16
votes
2answers
11k views
Handling Multiple Query Parameters in Jersey
In the web service I'm working on, I need to implement a URI with query parameters which look like /stats?store=A&store=B&item=C&item=D
To break it down, I need to be able to use query ...
13
votes
5answers
27k views
How do I get my current working directory in Java?
Let's say I have my main class in C:\Users\Justian\Documents.
How can I get my program to show that it's in C:\Users\Justian\Documents.
Hard-Coding is not an option- it needs to be adaptable if it's ...
11
votes
3answers
5k views
Fully qualified path Vs. Canonical Path
There is a canonical path concept in Java.
And there is a fully-qualified path in WinApi.
I know well what canonical path is, but I don't understand fully-qualified path's concepts.
For a file or ...
11
votes
4answers
7k views
export/import Eclipse build path
I like Eclipse's build path features, but would like to keep it in sync with my ant build.xml. Is there a way to either automatically import the Eclipse build path from a text file, or export the ...
10
votes
5answers
4k views
Pathfinding 2d java game?
First time on StackOverflow, keep see it coming up so thought id ask.
Im currently writing a very basic java game based on the idea of theme hospital.
I'm quite new to java, currently studying at uni ...
10
votes
3answers
5k views
Java - get “program files” path
How can I get the current computer's "Program Files" path with Java?