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.
Path to executable?
Hi,
I tried to use App.ExeName to locate the current executable.
This function exists in Jabaco, but returns an empty string.
Any idea how to find my own executable?
I'd like to know the path to open a configuration file in the same directory.
Greetings
A1880
I'd like to know the path to open a configuration file in the same directory.
Why don't you just open it like this:
|
Jabaco Source
|
1
|
Dim file as vbfilehandler = open "yourfile"
|
Just open "yourfile" and it's okay. No need of EXEName.
And App.Path works
To open it (second way) do this:
|
Jabaco Source
|
1
|
Dim file2 as vbfilehandler = open app.path + "" + "yourfile"
|
Hi,
App.Path points to the current working directory which was true when starting the application.
This is not necessarily the directory of the executable.
Example: I start my Jabaco IDE via a desktop icon. This determines the current working directory to be somewhere on my desktop.
Far away from the Jabaco project directory.
But you are right: When you compile an exe file and start it using the exe's directory, App.Path works as expected.
Opening a file without specifying the path, leads to the same situation:
The file is assumed to be in the current working directory.
One workaround would be to start the exe in the directory of the configuration file.
But this is not really flexible for using Jabaco executables from CMD skripts.
Greetings!
A1880
Hi,
i found something - maybe it's interesting:
|
Jabaco Source
|
1
2
3
4
5
6
7
8
9
10
11
12
|
Public AppPath As String
Public Sub Form_Load()
AppPath = GetAppPath
MsgBox AppPath
End Sub
Public Function GetAppPath() As String
Dim appURL As URL
appURL = getClass.getResource(".")
Dim s As String = appURL.getPath
GetAppPath = Replace(s, "%20", " ")
End Function
|
in fact it returns the folder that jabaco creates in the temp-directory.
greetings
OlimilO
works onlu in IDE for me
I tested this code and it works perfectly here (though changing "URL" with "url" in line 8 ) when i launch the app in jabaco IDE.
But, if i compile the program, it gives the error reported below.
Any ideas about why?
Java.lang.NullPointerException
at Master.GetAppPath(Master.jsrc:12)
at Master.Form_Load(Master.jsrc:6)
at VB.AbstractForm.fireLoaded(AbstractForm.jsrc)
at VB.LoadAdapter.run(LoadAdapter.jsrc)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$000(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.awt.EventQueue$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
moreover app.path doesn't wok even in a .exe complied project
Try the following:
|
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
24
25
26
|
Option Explicit
Public AppPath As String
Public Sub Form_Load()
AppPath = GetAppPath()
MsgBox AppPath
End Sub
Public Function GetAppPath() As String
Dim classPath As String = System.getProperty("java.class.path")
Dim pathSeparator As String = System.getProperty("path.separator")
Dim fileSeparator As String = System.getProperty("file.separator")
Dim cp() As String
Dim s As String
cp = Split(classPath, pathSeparator)
s = cp(0)
If Right(s, 8) = ".exe.jar" Then
cp = Split(s, fileSeparator)
s = Left(s, Len(s) - Len(cp(UBound(cp))) - 1)
End If
GetAppPath = s
End Function
|
Greetings
A1880
Thank you very much!
It somehow works, even if under IDE it returns the program working folder, compiled as JAR, it shows the complete file.jar file path and compiled as .EXE it gives a \temp folder path....
It's a shame ther is not an easy, direct way to geth the program folder path!
Hey there,
I just happened to read this and thought maybe
this is interesting for you too!
App.EXEName does not return paths in VB6, just a simple name. For "C:\blahblah\Project1.exe" for example it returns "Project1" alone.
App.Path is supposed to return the path to the compiled EXE w/o the "\" as in "C:\blahlah" alone. However it is broken in Jabaco and returns the current directory. This is very sad.
Speaking of that, the ChDir statement is completely missing in Jabaco.
You can use "CurDir" or System.getProperty("user.dir")
.
.
Spare me, im new to Programming
This post has been edited 1 times, last edit by "spysonic" (Aug 26th 2014, 2:55am)