Using Virtual Folders within Eclipse PyDev Workspaces - eclipse

I'm currently working through some Machine Learning tasks using Eclipse and PyDev.
This requires access to some large datasets of ~10K images. I didn't want to copy these large folders into the workspace, so the 'neat' solution seemed to be to import them as Eclipse 'virtual' folders (i.e. a link).
Several hours of processing later, this seemed to have worked...however, when I then try to access the virtual resources I generate:
FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\default\\training_set'
After stepping through, it became clear from using os.listdir() that whilst Eclipse may show virtual resources as being locally addressable, Python does not (shattering my vague assumption this would all be automatically handled by Eclipse).
My question is, within the PyDev environment, is there a way of using this functionality - or do I have to either fully import all my resources or use absolute file paths

Related

Automatic SVN revision number?

I write Android stuff using Eclipse+the ADT plugin. For VCS I use SVN.
What I am trying to accomplish: have my program, in its 'About' screen, display the SVN revision number it was built from. Obviously, this better be automatic. We cannot assume the program will have network access when run so this info has to be known at compile time.
Today I've been researching this topic and seems like this seemingly common scenario is actually not so easy to do or I am missing something. Lets see:
1) first approach: write a 'pre-commit' SVN script that, on each commit, would update a little file, that would be named 'revision' and would be located in the root of my project. Then writing a function that would open this file, read the revision number and put it in the 'About' screen would be trivial.
This doesn't quite work as the file would be updated server-side. So imagine this scenario: I check out rev. 3708, modify, commit, pre-commit creates 'revision' with '3709' in it. I build - and my local 'revision' still contains '3708'. Not good.
2) I hear ( Getting SVN revision number into a program automatically ) that SVN has this clever feature that it is able to replace various magic strings in your files, one of then being 'Revision', if one sets appropriate SVN metadata on all files in a project under SVN control.
This does not quite work again, because of the problem mentioned by user 'Smashery' in the link above - namely, SVN will only replace the 'Revision' magic string in files that got changed during the last commit.
3) Write a 'pre-build' Eclipse script, and have it run 'svnversion /path/to/your/project' and save output of this in /path/to/your/project/revision.
This does not quite work again - I mean, I have tried and writing such script is actually surprisingly easy. If I were working on a single computer, it would have worked for me - but unfortunately I work on two computers, one Linux machine in home and another Windows machine at work. I keep switching machines every day (during the day Windows, in the evenings Linux at home).
The problem here is with Eclipse: as soon as you add a 'pre-build' script, it creates a new hidden directory in your project folder ( .externalToolBuilders ) , which, among other things, contains the absolute path to the script to run (obviously). This path cannot be the same on both of my machines (being Linux and Windows). In order for things to be automatic, I need to check this in to SVN, and as soon as I do, things will work only on one of my machines unless I keep manually correcting the path every day!
Any ideas?
Third way (slightly polished) can be and will be The Right Way, if you'll grok some things
Workplace specific settings must not be shared and stored in repository: ignore .externalToolBuilders on both locations but configure Eclipse differently according to your needs and settings
Except identical for all OSes svnversion (and don't forget ignore also /path/to/your/project/revision, because build-artifacts must not be part of repository) you may want to use more powerful somehow subwcrev (on Win-box) and svnrev (on Linux-box) in pre-build event - svnrev also contain some useful reading

.emacs.d folder equivalent for eclipse

I want to know if there is any place where eclipse stores all my configurations so that only the config files can be ported across different machines(even different OS's)
If I spend my time customizing eclipse on my desktop , spending the same amount of time on every machine I work on is a no brainier. I was hoping eclipse stores its files in some directory in home directory(~/.emacs.d on linux/mac mainly, but use windows often as well) just like emacs does. With this I can easily put all my configurations under VCS and get exactly the same look and feel on every machine. I have done this for emacs actually and it works great. Like this https://github.com/anooprh/dotfiles/tree/master/emacs.d
I could not find anything like that for eclipse. The closest I could find was .eclipse folder in home directory
[user#localhost .eclipse]$ pwd
/home/user/.eclipse
[user#localhost .eclipse]$ ls
org.eclipse.platform_4.4.1_1473617060_linux_gtk_x86_64 org.eclipse.platform_4.4.1_1756587775_linux_gtk_x86_64
I dont know what these two directories. Inside that there were was a configuration directory as well, but could not find anything useful.
I want to know from people who have been using eclipse for some time as to how they manage to port their config files from one machine to another.
Thanks in advance

How to distribute my Java program so that it is runnable by double-clicking a single file?

I have a Java rich client desktop app. that I want to distribute on some computers at work, but I've never done something like this before. People aren't too computer-savy at my workplace and since it is a student job, I won't be there for much longer and I'd like it if I could make my program easy to run by making it runnable when people double-click on it.
I also don't want to have to manually install a JRE to have it run. Basically, what I'd like to know is how to make my java application runnable easily by double-clicking (even if it's only on windows, it's okay). I'm pretty sure I'm going to need to package the correct JRE version alongside, but I don't know what's the correct way of doing this.
I read on some sites that you should not package a JRE along with your program because it makes people have multiple different versions, some of which are outdated, and it causes security issues, but this is not a problem in this case since the computers that are going to run my application are not connected to the internet and are only used to run this program anyway.
Somewhat related question: Since my application is currently an Eclipse project, I get my resources such as icons, images, SQLite database (for read and write), etc. using relative paths (e.g.: img/test.png).
Am I going to have to change any of those paths to have them keep working even while packaged?
What you're looking for is a JAR file. In eclipse, it's quite easy to make a Jar file. Specifically, you'll want to right click on your project, go to Export, and then select "Runnable Jar." Be careful with paths to folders. You may need to keep a resources folder next to the Jar file. You may need to provide some more specifics to get an exact answer on that. Typically, a Resources folder is located in the same spot as the JAR file (in the same folder on your computer).
A better option for easy install of a Java app. with a GUI is to launch it using Java Web Start. For the user, JWS is the 'one click' installation option that can (install & launch the app. then) add desktop shortcuts and menu items. A JWS launch would mean some more work for you, but it is a breeze for the end user.
To ensure a suitable JRE is present to run the app., use deployJava.js (see the JWS link for more details). The script would need to be reconfigured to get the JRE installer from your local network - the default is to get it from Oracle.
Most of the resources should be packaged in Jar files and supplied along with the app., but for the DB, use the JNLP ExtensionInstallerService to call the DB installer.
..Java Web Start is kind of a link (or I can make it a shortcut on the desktop) that the users will click to either install the JRE and run the program if the JRE isn't installed, or just run the program if the JRE is present on the computer.
The way it would work is to have a web page on the local intranet. When the user visits the page, the script checks for a suitable JRE.
If it is present, it writes the link to the launch file.
If there is no JRE, or the version is too low, it will guide the user through installing it (just a matter of them clicking 'OK' when prompted). Then it will put the link to the app.
I can then configure the link to grab the JRE from the server on our network.
That's the part where you need to reconfigure the script. AFAIR the script exposes an URL at which to look for JREs - that can be changed to point to a place on the intranet.
..So "Web" is only just in the name, the computers don't have to be connected to the internet to have this work, right?
Yes. JWS is a great launch technology for Java rich clients, but is a poorly chosen name.
To make the problem run by double clicking it you can distribute it as a jar file or a batch file to call the jar file.
For the installation part you can make a batch file that checks if java is present and then call the installer if it isn't.
Edit:
The batch code:
IF DEFINED JAVA GOTO ok
java-installer.exe
GOTO end
:ok
your-application.jar
:end
If you are finding it tough to implement the above mentioned methods. You can proceed with this simple approach.
Create a folder lib at a location. Place all the jars that your application uses into this. If you are able to create a jar for your application, you can very well place your application.jar into the lib folder too. Create a batch file at the same location that will contain the java command for your main class in it. The text within your batch might look something similiar to this :
set path="\lib\"
java -cp %path% package1.package2.MainClass
If you have any other dependencies, for ex: if you use images in your code under img/icon.jpg. Then you just have to shift the img folder to this location too.
Just zip these files using winrar and share it across. Running the batch file after extracting the zip would launch your java MainClass irrespective of the location in which it is placed in the client system.
PS : If you are unable to create a jar for your application and placing it in lib folder, just copy your bin folder with class files and paste it in the location and change the batch file accordingly to look for classes inside bin.

Portable Eclipse

I'm trying to port my entire 'workspace' to a USB key (including the Eclipse executable) so that I can carry my work anywhere with me and work off the key directly.
My directory hierarchy is similar to this:
/workspace/eclipse - Where my current eclipse binary is stored
/workspace/codebase - Where I keep the root of all my eclipse projects
/workspace/resources - Where I keep all project files (images, docs, libs, etc.)
It all works perfectly fine on one system. But when I change over to another system, the USB key gets mounted on another drive. For example, on my laptop, I get 'E:\', on my PC, I get 'K:\' and at work I get 'F:\', etc, etc.
This means that because Eclipse (for 'some' reason) seems to only use full path names (including driver letters) in every single one of its configuration files (such as .classpath), nothing ever works when I want to work on another system.
I put a 'libs' directory in the base of every project and populate it with its dependent JAR files. Why doesn't it use relative names instead, so that I could specify something like "../../libs/log4j.jar"?
Anyone know how to fix this problem? Does anyone know of a workaround for this?
Update: 2010.11.09
I've recently discovered Dropbox, which allows you to sync your files online and across your computers automatically with extreme ease. It includes 2GB of free space and you can upgrade to much more if you want (for a yearly fee).
I installed it on my two laptops, my two PC's, my Linux server and my Android phone and then I created a 'workspace' directory within the 'My Dropbox' folder. From the 'workspace' directory, I then installed Eclipse and created/configured all my projects as usual. I can literally work from any computer and everything always stays perfectly in sync. This is way better than any USB key functionality and its hassle!
Have you tried using Eclipse Portable?
The only thing to keep in mind is that when switching the workspace, you need to remember to give it a relative path (like ../../Data/workspace).
You could use the dos command subst to get a consistent drive letter by creating a new virtual drive letter (say x:) that maps to your Eclipse folder on your usb drive, and then make all the config paths reference the drive x:
You could make a little batch file on the usb drive that you click on to create the drive x:
C:\>help subst
Associates a path with a drive letter.
SUBST [drive1: [drive2:]path]
SUBST drive1: /D
drive1: Specifies a virtual drive to which you want to assign a path.
[drive2:]path Specifies a physical drive and path you want to assign to
a virtual drive.
/D Deletes a substituted (virtual) drive.
Type SUBST with no parameters to display a list of current virtual drives.
You could also remap letter for your USB stick in Windows Disk Management (subitem in Computer management) to be smth like 'U:'.
Once done, it will be re-assigned to same stick every time you plug it. Not very universal, since your user need rights to access this setting first time, but it could help in some different scenarios.
You can always use Ant to build your programs, with Ant you can have relative paths... Plus you can also use Ivy to track dependencies in Ant, I do that in every project that I have.
Another alternative is to manually edit your .classpath files to contain relative paths.
It is a bit of a hassle, though, as you'll have to manually update the files whenever Eclipse changes them.

Do I have to build my LabVIEW instrument driver under Program Files?

I'm trying to build a LabVIEW plug and play instrument driver project for a device we sell. I followed the instructions to create a project, and it created the project in with the LabVIEW program:
C:\Program Files\National Instruments\LabVIEW 2011\instr.lib
I suppose I could connect that folder to source control and just do all the work there, but it feels weird to be working under Program Files. When I tried to move the project folder out into my regular workspace folder, it broke all the subpalette files (*.mnu). I could recreate them, but I'm afraid they wouldn't work for our customers when they install the driver from the LabVIEW web site.
Is it possible to move a driver project around, or does it have to stay in the default location? If one of our customers has installed LabVIEW in a different location (say on drive D:) will the driver menus not work for them?
I'm not in favour of user.lib for SCC'd items. using several LabVIEW versions at a time is a big problem.
Here is my routine:
Create the instrument library and save all code in a folder starting with an underscore ('_') (_foo)
Create an .mnu file in the parent folder of '_foo' Mylib.mnu, add the icons you need.
With OpenG package builder I create an installer routine that placed the the mnu file and the folder in instr.lib
After a restart of LabVIEW the instrument driver shows up in the instruments palette.
If you keep the code in the same relative position to the mnu file there is no problem with missing VIs.
Ton
Instrument drivers are always located in the 'instr.lib' folder in the current LabVIEW version folder. There is an environmental path set up in LabVIEW for this intrument driver folder so it will always point to the correct drive for the installation of LabVIEW used.
You should keep the folder in the location used by the wizard to ensure that when distributed to your customers the sub palette menus point to the correct location and all the VIs link correctly.
I use source control for user.lib which is in a similar location and have no problems.