Getting started with Web Application
From Tauwiki
(Redirected from Version Check Help)
- # 1) import following three classes.
- import java.io.UnsupportedEncodingException;
- import java.net.URLDecoder;
- import java.net.URL;
- # 2) Declare a variable
- static String parentDir=null;
- # 3) paste it in main method.
- # create a object for ur main class
- # example- JApplet applet=new Interpolate()
- # use above object to get jar file location.
- try {
- URL url =
- applet.getClass().getProtectionDomain().getCodeSource().getLocation();
- String sPath = URLDecoder.decode( url.getPath(), System.getProperty(
- "file.encoding" ) );
- File f = new File( sPath );
- if( !f.isDirectory() ) {
- # //then it's the .jar file and its parent file will be the dir the .jar
- #file is located in.
- parentDir = f.getAbsolutePath();
- }
- else { //then the class is not inside a .jar file
- parentDir = f.getAbsolutePath();
- parentDir=parentDir+"/Interpolate.jar" ; // if it is Interpolate.jar
- }
- } catch(UnsupportedEncodingException exp) {
- }
- String className1;
- className1 =
- new Throwable().getStackTrace()[0].getClassName();
- final String className=className1.substring(className1.lastIndexOf('.')
- + 1, className1.length());
- class VersionThread extends Thread {
- public void run() {
- FitsVersionCheck.versionCheck(className, version, parentDir);
- }
- public void run() {
- }
- VersionThread t=new VersionThread();
- t.start();
