How to get a file in the same dir with the jar-executable
Hi,
I need to read/write a file that exists in the same directory with the jar-executable. How can i do that? I think that when i specify no path for the file, the file has to be in current path. (Is that right?)
Note: I do not know in which directory the jar and the file are.
Thanx in advance
Hi,
I need to read/write a file that exists in the same
directory with the jar-executable. How can i do that?
I think that when i specify no path for the file, the
file has to be in current path. (Is that right?)
Note: I do not know in which directory the jar and
the file are.
Thanx in advance
When you specify no path for the file, the file has to be in the directory where the virtual machine was started. ( the directory the java command was invoked in .)
If you can't control the directory in which the vm is started, but you know the name of the .jar file you can do the following. This trick takes advantage of the fact that if you are using classes in a jar file, the name of the jar file must be in your classpath.
public static String getPathOfJar( String nameOfJar )
throws Exception
StringTokenizer st = new StringTokenizer(
System.getProperty( "java.class.path" ) ,
System.getProperty( "path.separator" ) );
String jarfile = "";
while ( st.hasMoreTokens() )
String token = st.nextToken();
if ( token.indexOf( nameOfJar ) > -1 )
jarfile = token;
break;
if ( jarfile.equals("") ) throw new Exception( "Jar not found in classpath" );
String path = jarfile.substring( 0 , jarfile.indexOf( nameOfJar ) );
return path;
//To open a file in the same directory as the sun archive tools.jar
File f = new File( getPathofJar( "tools.jar" ) + "someFile.txt" );
Similar Messages
-
When our iPad is in use on the internet, my iMac internet connection goes off. I can't get the two devices to work at the same time with the AirPort Express. Is there a setting somewhere I may have missed?
When two or more devices conflict it typically means that the DHCP service is either misconfigured or is not running at all. DHCP provides IP addresses to local network clients.
Is your AirPort Express base station the only router in your current network configuration? That is, is it connected directly to an Internet modem and not to another router upstream of it? -
my iTunes library is on an external hard drive; how do I set it so other users (accounts) on my imac, will also have the same library, with the same playlists
Quit iTunes.
Sign into another user account.
Hold Option, launch iTunes.
Select Choose library... and select the iTunes folder on the external.
Do this for all users.
NOTE: You must quit iTunes when switching users as the library can only be opened by one user at a time. -
From the day 01/04/2014, I can not even update the apps on my iPad 4 or buy via my iPad. The same happens with the iPad mini ... My internet connection being excellent. I usually can get with the devices on the Internet, the App Store, enter into any service of any Cloud Apps. But I can not update or buy apps App What is happening?
You shouls be seeing this (tap to enlarge image)
-
How Do I Sort a Group of Photos on the Same Page with the same Keyword Tag?
I want to group similar photos on the same page with the same keyword tag. I have tried dragging and dropping without any success. Can anyone help?
Create an album, then search using a keyword. Select all the photos produced by the search and drag them into the album.
You can drag photos into any order in Albums and they remain in your chosen order.
-
Put the prompt on the same screen with the report
Hello all,
I have a prompt on a report and when i run the report i will first get the prompt after i select the prompt elements then it will take me to the report and i have a request now to put the prompt on the same screen with the report. I am curious to know how i can do that. Could you please let me know
Thanks,
RC
Edited by: user1146711 on Nov 4, 2011 8:59 AMHere you are looking to have report prompt and report on the same page which is not possible.
If you still want to achieve this ..then create a report with all columns say reprot1 and report2 your prompts.
Go to dashboard ...add ...report2 prompts on the above...report2 with all columns 1 down...
Now when you see .....report prompts on top and report on down....now when you select some prompt it will take you to the new page....
Use guided navigation. -
Why can't I open some of my documents on Pages even though I created them all on the same IPad with the same Pages ap?
I think I know the problem because I've had it myself. I didn't upgrade iWorks on my iPad, but after Apple made changes to iCloud (concurrent with Mavericks) any docs passing through it were modified and made unreadable. Even though, as you say, they were created on my iPad using the previous version of iOS Pages, which I didn't upgrade.
iCloud is the culprit, if your iPad settings had iCloud>Documents & Data enabled, the docs were modified and disabled in the cloud.
I made a further mistake. After I saw this happening, I didn't think to turn off auto updates, and Apple pushed the new version of iOS Pages onto my iPad. The result was that ALL my docs disappeared from the iPad, and from iCloud.com also. I have not been able to recover them.
I've been talking to the Pages engineering team about it. If they come up with an answer, I'll post it here. Meanwhile, get those older files backed up somewhere safe if you can. -
Ating system and Ipod doesnt recognise my pc so I cant sync the same ipod with the same pc?
I have recently upgraded my os to windows 7 and had to uninstall my Itunes in order to do so. Now that it is installed Itunes doesn't recognise my laptop and thinks it is a different computer and won't sync my Ipod with it. I'm using the same computer with the same Ipod but can't download to my Ipod unless I wipe everything from it and sync it with a new library that doesn't have as much music as my Ipod.
How do I sort this ?Try restarting your iPod. Press and hold the On/Off Sleep/Wake button until the red slider appears. Slide your finger across the slider to turn off iPhone. To turn iPhone back on, press and hold the On/Off Sleep/Wake button until the Apple logo appears.
Tap the App Store app. See if you can download apps. -
Hello, I am having some major troubles connecting my iPhone 4S to my home wifi. When I try to connect on my phone, it says I have an incorrect password. That's not possible because I can connect my MacBook to the same network with the same password. I have reset my network settings on my phone, reset my router, called apple support, triple checked I was trying it in correctly, I have no clue what's going on.
The only thing different is I just moved, but I have the same router/phone/internet provider.
I've seen some discussions of router security options being the problem, I have my router connected to : WPA-PSK [TKIP] + WPA2-PSK [AES].
The other options are: WEP , WPA-PSK[TKIP] , WPA2-PSK [AES] , WPA/WPA2 Enterprise.
My troubleshooting and understanding of all this is pretty limited, my applecare service did not help, please can anyone help me?
Thanks!If the issue happened after an update, you may want to go into an Apple Store. Be sure to let them know exactly what's wrong with the device.
-
Can you use 2 sets of bluetooth headphones at the same time with the Ipad 4?
Hi, I was wondering if anyone could tell me if I can use 2 sets of bluetooth headphones at the same time with the Ipad?
It is so my children can watch a film or listen to music together.
ThanksNo
-
i paid for the single after effects cc app and I used the same account with the expired free trial . so after paying for after effects, i try downloading it but it brings up a screen saying that i need to purchase after effects to continu
Activation Stuff
Mylenium -
I have installed the Dreamweaver programm on my desktop. Can I also install the same version with the same license on my laptop ?
yes, adobe single user licenses allow up to two concurrent installations,.
-
My airport express only flashes amber even when it's in the same room with the modem.
I want to set it up as a wi-Fi extender.Your AirPort Express can only extend a wireless network provided by another Apple router if you want the network connection between them to be wireless.
What is the make & model of the wireless device that you are trying to extend with your Express? -
I have an iPod Touch 8GB 2nd gen and it's only showing connect to iTunes screen and not letting me past that as I have a password - Already reset and it just loops back to the same screen with the same problem.
Any idea what I can do to fix this?you can connect the iPod to iTunes in recovery mode:
Hold down the Home button and the Power button simutaneously, until the screen goes black and the device turns off.
Now let go of the Power button, but continue to hold the Home button. Your iPod Touch/iPhone should have turned off and the screen should not be on.
After around ~10-20 seconds, you will hear a noise (beep/ding) from your CPU as if it had just recognized a new hardware device
and restore it to default settings, in order to remove your password (or just remove your password directly from the iPod touch, in order to sync with iTunes) -
Is student version released at the same time with the full version?
I downloaded the LR4 to see how it compares to a LR2 I have at the moment. Adobe clearly states that users testing the beta can get the full version after March 31, but I did not find any information regarding the the student version release. Has adobe released the student versions simultaneously with the full versions, upon product release?
In the past, the student version has been the same price as the upgrade, and it has been possible to upgrade to a standard version from a student version. If that continues to hold, you'll be able to get LR4 immediately for the equivalent of the student price. Notice the "if" in that statement.
Hal
Maybe you are looking for
-
My iPhone 5 can no longer be recognized, therefore can't sync?
I have tried two different USB wires, and they both won't work. They use to work before, and I have tried using the wires to charge the phone by wall, and they both work fine. I also tried reinstalling (three times already) itunes, mobile device supp
-
Unknow error when sending mail (MS Exhange)
Hello, Since yesterday I get the following message when i want to reply to a message or just want to send a new mail (MS Exchange) I allready did the restart / swap battery. Does anobody knows how to solve this problem ? Regards Post relates to: Pre
-
I updated my iphone 5 to ios7 on Sunday and have been having m?ajor problems with my phone since. It keeps freezing and I have to constantly press the home and on/off switch to get it to restart. I had updated my itunes and backed up the phone befo
-
Does the ASA5525-K9 support Content filtering?
Hi, I know the 5510 & 5520s support the CSC-SSM module for Content Filtering (Anti-Phishing, Anti Spam, URL filtering, Anti-Spyware & Antivirus), but what about content filtering for the ASA5525-K9. The problem that I have is that I need a firewall t
-
DC making query to port 53(udp) on client machines
After some network troubleshooting with our network engineers it was noticed that the domain controllers were trying to make connections to port 53(udp) on client machines. There is nothing in DNS that would suggest there is a reason for this. Is thi