You are not logged in.

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.

A1880

Intermediate

  • "A1880" is male
  • "A1880" started this thread

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

1

Saturday, September 5th 2009, 11:08pm

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

klctal

Trainee

  • "klctal" is male

Posts: 70

Date of registration: Jul 13th 2009

Location: Shanghai

Hobbies: Developing software

  • Send private message

2

Sunday, September 13th 2009, 8:15am

Quoted

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"
:D

A1880

Intermediate

  • "A1880" is male
  • "A1880" started this thread

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

3

Sunday, September 13th 2009, 11:56am

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

OlimilO

Intermediate

  • "OlimilO" is male

Posts: 277

Date of registration: Jan 18th 2009

Location: Germany

Occupation: software engineer

  • Send private message

4

Monday, September 21st 2009, 9:51pm

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

Giasone70

Beginner

Posts: 8

Date of registration: May 7th 2011

  • Send private message

5

Friday, June 10th 2011, 1:02pm

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)

Giasone70

Beginner

Posts: 8

Date of registration: May 7th 2011

  • Send private message

6

Friday, June 10th 2011, 1:10pm

moreover app.path doesn't wok even in a .exe complied project

A1880

Intermediate

  • "A1880" is male
  • "A1880" started this thread

Posts: 500

Date of registration: Jan 1st 2009

Location: Hanover, Germany

Occupation: Software Engineer

Hobbies: Hilbert Curves

  • Send private message

7

Friday, June 10th 2011, 3:01pm

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

Giasone70

Beginner

Posts: 8

Date of registration: May 7th 2011

  • Send private message

8

Friday, June 10th 2011, 3:55pm

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!

Dani

Intermediate

Posts: 325

Date of registration: Nov 19th 2009

Location: GERMANY

  • Send private message

9

Friday, June 24th 2011, 1:44pm

Hey there,
I just happened to read this and thought maybe
this is interesting for you too!

dilettante

Beginner

Posts: 8

Date of registration: Jan 28th 2011

  • Send private message

10

Saturday, June 25th 2011, 2:53am

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.

spysonic

Trainee

  • "spysonic" is male

Posts: 88

Date of registration: Jul 11th 2014

About me: A beginner programmer.

Location: ...Jabaco Academy

Occupation: i have some but still not enough...

Hobbies: Jabaco

  • Send private message

11

Thursday, July 31st 2014, 6:48am

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)


Rate this thread
WoltLab Burning Board