Dear visitor, welcome to Jabaco - Community. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.
Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming
Quoted
I am trying to find the App.Path.
Jabaco Source |
|
1 2 3 4 5 6 7 8 |
Public Sub Command1_Click() MsgBox App.Path ' MsgBox CurDir ' MsgBox TmpDir ' MsgBox TempDir ' MsgBox HomeDir ' MsgBox JavaDir End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 |
Public Sub Command1_Click() MsgBox VB#FileSystem.CurDir ' MsgBox VB#FileSystem.TmpDir ' MsgBox VB#FileSystem.TempDir ' MsgBox VB#FileSystem.HomeDir ' MsgBox VB#FileSystem.JavaDir End Sub |
Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming
In fact if I try to declare it as an object, I can't even get that method from the list.
See Pic Below.
Jabaco Source |
|
1 |
Debug.Print Replace(Replace(Left(getClass().getProtectionDomain().getCodeSource().getLocation(),InStrRev(getClass().getProtectionDomain().getCodeSource().getLocation(), "/")),IIF(Left(Mid(getClass().getProtectionDomain().getCodeSource().getLocation(),8),1)=":","file:/","file:"),""),"%20"," ") |
Jabaco Source |
|
1 |
Debug.Print Mid(getClass().getProtectionDomain().getCodeSource().getLocation(),7) |
Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming
I know it is a bit of an overkill but this has proven to be reliable on Win and Mac with the compiled program:
Jabaco Source |
|
1 |
MsgBox New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath
|
Jabaco Source |
|
1 |
MsgBox New java#io#File(getClass.getResource(".").toURI.getPath).getAbsolutePath
|
Quoted
OlimilO changed it to the user dir:
Jabaco Source |
|
1 |
New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath
|
Jabaco Source |
|
1 |
New java#io#File(getClass.getResource(".").toURI.getPath).getAbsolutePath
|
Jabaco Source |
|
1 |
New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath
|
Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming
Source code |
|
1 2 3 4 5 |
Public Sub Form_Load() Dim gLP As String gLP = App.Path Debug.Print gLP End Sub |
Maybe it's just me or my machine, but this code doesn't work for me.
Jabaco Source |
|
1 2 3 4 5 |
Public Sub Command1_Click() Dim gLP As String gLP = App.Path Debug.Print gLP End Sub |
Jabaco Source |
|
1 2 3 4 5 |
Public Sub Form_Load() Dim gLP As String gLP = New java#io#File(getClass.getProtectionDomain.getCodeSource.getLocation.toURI.getPath).getAbsolutePath Debug.Print gLP End Sub |
Jabaco Source |
|
1 2 3 |
Public Sub Form_Load() MsgBox getClass End Sub |
Jabaco Source |
|
1 2 3 |
Public Sub Form_Load() MsgBox System.getProperty("sun.java.command") End Sub |
Jabaco Source |
|
1 2 3 |
Public Sub Form_Load() MsgBox Class.forName(System.getProperty("sun.java.command")) End Sub |
Jabaco Source |
|
1 2 3 |
Public Sub Command1_Click() MsgBox Class.forName(System.getProperty("sun.java.command")) End Sub |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
import javax.swing.*; public class Test extends JFrame { public Test(String s) { super(s); try { System.out.println(Class.forName(System.getProperty("sun.java.command"))); } catch (ClassNotFoundException e) { System.out.println("*** Error: " + e); } //System.out.println(this.getClass()); } public static void main(String[] args) { Test f = new Test("My Window"); f.setSize(100,100); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } } |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
import javax.swing.*; public class MyFrame extends JFrame { public MyFrame(String s) { super(s); try { System.out.println(Class.forName(System.getProperty("sun.java.command"))); } catch (ClassNotFoundException e) { System.out.println("*** Error: " + e); } //System.out.println(this.getClass()); } } |
Jabaco Source |
|
1 2 3 4 5 6 7 8 9 10 11 12 |
import javax.swing.*; public class Test { public static void main(String[] args) { MyFrame f = new MyFrame("My Window"); f.setSize(100,100); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setVisible(true); } } |
Quoted
To fix the problem a german Java community have helped me:
[ http://forum.byte-welt.net/threads/10058…s-forName%28%29 ]:
Ich meinte, dass das nur 'ne Übung sein kann bzw. sein sollte, zumindest was die Klassen "Modul1" und "Form1" angeht.
1. Die Sache mit dem statischen JFrame (Form1)
2. Den JFrame noch nicht mal auf dem EDT konstruiert
3. Der MessageDialog bei jeder neuen Form
4. "setVisible()" in einem Konstruktor
5. Das sind alles NoGos und nur zu Übungszwecken oder KSKBs geeignet. Wenn man sucht, findet man gewiss noch andere Dinge.
Beginner
Date of registration: Jan 15th 2011
Location: Sarasota, FL
Occupation: Cabinet Design
Hobbies: Programming