Whenever I run my script a temp file gets created in my local directory:
something like: "webdriver4726826335276373500libs"
inside the folder: IEDriver.dll
at first I thought it was this issue
How to stop Selenium from creating temporary Firefox Profiles using Web Driver?
but that does not seem to be the case, I do not think that IEdriver uses profiles.
This is a problem for me because it is eating up my hd space.
does anyone know why this is happening?
The core of the IE driver is contained in a COM dll written in C++. For certain language bindings (.NET and Java), this dll is extracted at runtime to a temp folder when you instantiate an instance of the InternetExplorerDriver class. These languages then use their native code invocation mechanism (JNA or P/Invoke) to call the functions in the native code dll. This methodology was chosen to reduce the requirement on the user to have the correct .dll (and the correct version of the .dll) in a known location. At present, it doesn't appear that the Java language bindings do anything to delete this .dll after the server is shut down, whereas the .NET bindings do. The report tracking this issue for the Java bindings in the project's issue list is issue #1140. As a workaround, you can manually delete these directories after running your tests, or it may be possible to create a short routine in your testing framework that will do the same.
The driver.quite() will automatically clears your temporary files. you better look at this.
Related
I would like to get the path to the working directory of a specific process (for example for the PID of the process). I am Not Talking about the working or current Directory of the process where my Java Code is running. Its a simple task with Linux, but for Windows i cant find a proper solution. Furthermore, it would be nice, if its a Command or a Framework for Java, because i will need the path in my Code. I am not looking for the path to the executable, also Not for a solution with wmic or process explorer.
Already thanks for the help.
I already tried commands like tlist and wmic, but those solutions cant be utilize in my code. I am looking for a solution that i can use without special installations on Windows.
JNI and JNA provide means to call directly into native libraries from Java code, and it is feasible to use these to call out to Windows libraries.
There is a github project that appears to be close to the need: https://github.com/kohsuke/winp. Perhaps you can add the needed code and send up a pull request, or fork the project.
Note that any solution here is going to be windows-specific, meaning the application using it will not run on another platform. Given the nature of the question, that doesn't sound like it would ever be a concern.
I am trying to implement something like virtual machine in Java. Yes, it NEEDS
to be made in java, since it wraps some already-coded java library and implements
it's abstractions. But on the problem...
The actual problem is that it is intended to run java programs written to be run
on UNIX platforms (e.g. They need to log to /var/log). I can load the jar, and launch it by invoking main method... But the real problem lies that whenever the file tries to access the filesystem, it crashes because the filesystem is not in proper format (e.g. It is missing /var/volatile as it is used commonly on embedded systems but rarely on full desktops). I am looking for a solution to translate default Java java.nio.File abstract pathnames to some other locations, or to make virtual FS in a file (like loop device), or anything similar, that would work like chroot for the program. I couldn't find a single soultion to this problem around the web. The real reason behind that is to allow users of any platform to run the VM without modifing the source code of the program being run in the VM.
Many Thanks.
i am currently writing a game on javaFX and i have plans to post it in the website i run in the future (end exploit the Ads while at it). The problem is that after searching around a little it seems there is no way to run a java application on a browser.
Allowing people to run it through the browser would really help sharing the program.
My question is: is there today(2018) any way to run a java application through the web? Though i like java, no browser support seems like a really, really bad idea.
Oh, i also heard of Java Web Start. Although it looks like it is just avoiding the problem (not running in the browser) it seems like a good way to share an application. The problem is that it seems it is (Will be?) deprecated? I am helpless, it is like java isn't even trying anymore...
PS: If it makes any difference my game would be a 2D game with 3rd person view. It will also require some server stuff since players will create "arenas" that others can challenge. I would say my game wouldn't be "simple".
Java Web Start does the job very well—if you are willing to pay for a code signing certificate. (They’re a lot more expensive than regular SSL certificates.) The idea is that a user clicks on a hyperlink on your page, which causes the user’s Java installation to launch your application (possibly after installing it). This requires users to have Java installed beforehand.
If you don’t have the resources or desire to go with a code signing certificate, you can look at https://docs.oracle.com/javase/9/deploy/self-contained-application-packaging.htm. It allows you to create native installation packages for JavaFX applications. The disadvantage: You need each platform to create an installer for it. Meaning, you need Windows to create a Windows installer, OS X to create an OS X installation image, and Linux to create a Linux package. Some may also require signing using native tools.
Java 9 includes the jmod and jlink tools, which are capable of creating a file tree with an executable shell script or .bat file. A major advantage is that you can build such a tree for any platform, regardless of your own platform, if you unpackage the foreign platform’s JDK on your machine. Another advantage is that the user doesn’t need to have Java installed at all. A disadvantage is that the script requires a terminal, unless running on Linux.
Of course, you can just go the manual route and distribute a zip file which contains your .jar file(s), a shell script you’ve written, and a .bat file you’ve written. It’s not elegant, but it’s better than nothing. But it may trip up some non-technical users.
There exist a number of tools which create a native executable from .jar files, but I am not familiar with them (and I prefer to avoid third party tools unless they are truly necessary).
Whatever approach you choose, the answer is the same: You distribute something on your web page which the user downloads and runs. Aside from the download process, the browser is not involved.
What you can’t do is have users run your application inside the browser. That is deprecated, with good reason: It’s a disaster for the browser performance, for the Java runtime, for security, and for the user experience. And Firefox has all but banned plugins, so you’d be locking out a substantial percentage of users.
I read SO q&a about launch java as windows service wrappers, but can't find/choose product, suitable for my requirements :
Wrapper reads all java launch parameters from config file. In registry must be only commands to run wrapper itself - path to exe and maybe path to config. Always grant admin rights to change app parameters in registry is not comfortable.
Working dir and path to application also must be in config. I want to place all wrapper files deep into program, because user not intrested in it.
No dependencies(.net, python, etc). I don't want to extend requirements of my program.
Free for every windows OS, include win64.
Simple and lightweight. Size of my program with all 3rd party jars is 12Mbytes. I don't want to add 20Mbytes wrapper.
Automaticaly restart if app process dies.
Preferably single exe files for all windows platform.
I try and lookinkg throught different wrappers and tired a bit. Best suitable till now is:
jslwin (http://jslwin.sourceforge.net), but i don't know how mature it is(version 0.99). Also parameter lists in config is a bit complex(need to edit parameters quantity).
winrun4j (http://winrun4j.sourceforge.net), but i don't know how mature it is(version 0.45). Also it needs a special class for working as a service.
Also i try or look throught:
YAJWS (http://yajsw.sourceforge.net/) too big (30mb), can't make it work with custom files layout.
Advanced Installer (http://www.advancedinstaller.com) too big (50mb).
nssm (http://nssm.cc/) store launch parameters in registry(no config)
winsw (https://kenai.com/projects/winsw) .net required, stops after process dies
commons-daemon, procrun (http://commons.apache.org/proper/commons-daemon/index.html) store launch parameters in registry(no config), can't understand this product, i think it's complex.
jsmooth (http://jsmooth.sourceforge.net) complex and old(last update 2007)
javaservice (http://forge.ow2.org/projects/javaservice/) old (last update 2006)
runasservice (http://runasservice.sourceforge.net/) requires .net
windows rktools - sc, instsrv, srvany (http://support.microsoft.com/?scid=kb%3Ben-us%3B137890&x=16&y=7) - store launch parameters in registry(no config)
jwrapper (http://www.jwrapper.com/) seems not what i need. It packs java program in exe file with JRE. It's not about windows services.
firedaemon (http://www.firedaemon.com/) not free. And maybe it's not what i need.
launch4j (http://launch4j.sourceforge.net/) cool ability "search or download java". Maybe i add something like this to simplify installation, but it is still not about subj.
Java service wrapper (http://wrapper.tanukisoftware.com/) not free for win64.
Tell me please which wrappers suits my needs? Or maybe i think wrong about wrappers above and some of them suits my needs to?
I have had similar issues over the years. Its not that they all are inferior, its that they are all pretty hard to integrate nicely with your own project.
You may want to check out stork: https://github.com/fizzed/stork
It'll help create launchers for your Java console or daemon apps, and they will work across all major platforms. There is also a maven plugin in case you wanted to tie it into your existing build process.
I'm not sure if JWrapper will fulfil all the requirements like 1 and 2 in the way that you want it since rather than you dictating how it does the launch and where it puts things etc JWrapper instead handles that stuff in its own way but it does produce executables for win/mac/linux and more importantly it does support windows service installation as well as macos and linux daemon installation:
http://www.jwrapper.com/guide-installing-a-service.html
The service support though is for paid licenses, the free version doesn't currently support it.
Disclosure: I work for JWrapper
Goal
I'm currently developing an application in Netbeans using the Netbeans Platform on Windows (a cross-platform solution would be wonderful but something hacky for Windows if required is fine for now). The application communicates with a native C++ DLL through JNA. The DLL sits in a specified directory which I cannot control or change - say C:\DLL.
The DLL itself loads some files for reading in values etc. but it does this using relative paths. So it requires the "current" directory to be C:\DLL. Again, this is something I can't change in this project. The DLL is something I have to communicate with as is (unfortunately).
Problem
For regular JAVA applications I've had the option in Netbeans to set the working directory of the launched application like shown below:
http://i.imgur.com/3HuQKS8.png
But in the Netbeans Platform framework/template there are no such options. For the most part it looks like Netbeans just makes the directory of the current file I have focused in the Editor pane to be the Current Working Directory.
So how do I go about doing this? I might be able to run the application through a shortcut that sits in C:\DLL but this doesn't help when I'm debugging the application through Netbeans.
I want to know how I can run/debug this Netbeans Platform application with the current working directory set.
Clarifying Netbeans Platform
The Netbeans Platform is an application framework of sorts. Has a pre-defined structure based on "modules" that interact to form the full application. The whole thing is hosted inside the Netbeans Platform environment which provides each of your modules with tabbed/docking windows. Kind of nice to develop larger applications.
More information here: https://netbeans.org/kb/trails/platform.html
I've resorted to using chdir as #technomage (I can't seem to upvote his/her comment with my current account status) has also suggested.
To do this, I used the following piece of code before I load up my C++ DLL through JNA.
NativeLibrary clib = NativeLibrary.getInstance(null);
int result = clib.getFunction("_chdir").invokeInt(new Object[]{"<PATH GOES HERE>"});
Source: https://www.java.net/node/643965#comment-821128
You can also check the result by checking the result variable. Should be zero if everything went well.
I am not quite sure why null works for NativeLibrary.getInstance. The documentation doesn't say anything specifically about this and I haven't been able to glean anything from the source here: https://github.com/twall/jna/blob/master/src/com/sun/jna/NativeLibrary.java - But passing null does seem to get you the default libc or equivalent for your platform.
Note also that I had to add an _ (underscore) to the function name. This has to do with how function calls get mangled when compiled on Windows. As far as I know, this isn't required on other platforms, but I don't have the ability to test this right now.
Since I was unsure about whether my call was actually working, I did the following first:
Function f = clib.getFunction("_chdir");
This returns a function "pointer" f that you can trace/debug to see if you have a valid reference. Luckily, in my case, all I had to do was add the underscore as was suggested in the source link above.
After this call to chdir, the C++ DLL I need to access has been happily accessing files relative to the location specified in chdir.