I'm a newbie to Linux systems and recently I started using Ubuntu 10.04. When I do java development in Windows, I usually keep my project files under some drive (D: for example) and under my development folder, such as D:\projects\myproj. But I'm bit confused with Ubuntu's folder structure. So, I just want to know how do you organize your projects in Ubuntu? Under which folder do we keep our projects file?
You can do anything you want, but typically if you develop in a directory that is not under your home directory, you'll probably need administrator (root) permissions to set up the directories. Another reason to use a sub-directory under your home directory is that in larger companies, the home directories are often stored on a separate file server, which is backed up on a regular basis.
I usually create a directory workspace in my home directory, and then create project directories under that. Other developers may use src or projects.
On Unix-like operating systems (including Ubuntu, other Linux distributions, Mac OS X, Solaris, FreeBSD, etc.), you normally store everything under your home directory (typically /home/username in Ubuntu and many other Unix-like OSes, where username is ofcourse your username); not in an arbitrary folder in the root of your filesystem like you do in Windows.
Unix-like operating systems are multi-user systems at heart, unlike Windows, which is a single-user system at heart - that's why you're supposed to store all your own stuff only under your own home directory.
For example, make a folder /home/username/projects/myproj for your project.
To learn more about the Ubuntu directory structure, see LinuxFilesystemTreeOverview in the Ubuntu Community documentation.
Wherever you are comfortable with. e.g. /home/yourAccount/projects/yourProj
I've setup a different mount point to store user profiles. That way, even if the OS wont reboot after an update (I tend to use Alpha builds) user profiles are left intact.
I'm not sure how to do this after the installation procedure however, sorry.
I suggest Eclipse, like above, if you're looking for a perfect IDE.
I keep my main workspace in the home folder, then create projects, following the wizard (creates folders).
I keep them in my home folder under a work subdirectory. My default workspace directory for Eclipse is /home/tiwe/work/workspace
Use symlinks for shortcuts
I would just use Eclipse, go into the software installer for Ubuntu and find Eclipse under the programming section.
As other have stated, private stuff typically goes in your $HOME directory and I create all my projects under /home/pascal/Projects/. I then import them from there into an IDE. In other words, I don't store anything in Eclipse's workspace folder (I don't want to rely on anything IDE specific and I actually may use more than one IDE for my projects).
If really you want to use a separate partition (other than the one hosting /home), you can do so and mount it (typically under /mnt) and create a directory tree for your projects (and set user and group permissions, depending on the file system used). But I don't really see the point unless you're running out of space in your home, the other partition is faster or has a different backup policy.
Related
Upon installing the Eclipse IDE, a number of hidden folders are created (for example .p2 and .eclipse) under the user profile on the C: drive.
The problem I am having is that our user profiles at work are limited in size, and these folders exceed the limited amount.
If you attempt to move a folder to another location such as an external drive or network drive, Eclipse fails to start. I have tried searching for a config file whereby I could reappoint the file location, but have been unable to find anything of the sort. I presume it is set on initial installation.
So what I'm asking is - is it possible to move the location of .p2 (and potentially other hidden Eclipse installation folders), or is Eclipse dependant upon being installed into the user profile?
Many Thanks,
Dan.
The .p2 directory is where the Oomph installer puts everything it installs.
You can download 'package' installs which have a lot of pre-installed things which will be in the install directory wherever you put it.
Package installs are at https://www.eclipse.org/downloads/eclipse-packages/
For completeness I will also mention that there are also some package installs at http://download.eclipse.org/eclipse/downloads/ These are very minimal builds of Eclipse and don't include the Oomph installer at all. Everything you install using these builds will be put in the install directory.
I have a software tool that I am working on in Java. It will be deployed to both Windows and Linux. I am at the phase where I am trying to determine the best course of action for saving the user's installation directory (where i will store all external files). Ideally I want the user to be able to move the program to any directory they choose (even after installation) and it will still be able to find the installation directory.
I have considered using environment variables to save the path but I am not sure if that is the best practice.
What is the standard practice for saving a path to an installation directory on Linux and Windows? (I am open to making different install logic for each OS)
Edit
After a bit more research, I have found that the /etc folder for linux is where I should store data and the Registry for windows. Can anyone confirm this?
In Windows, registry works great. Here's an example from a product I use (evo5.0 with eurovoiceHMP):
Locations of config and logging folders can be configured manually via the registry,
eurovoiceHMP and evo5.0 then "find" these folders under registry:
HKLM/Software/eurovoice
Specific registry setting examples:
HKLM/Software/eurovoice/HMP:
evoHMPLicencePath C:\ProgramData\eurovoice\HMP\Config\Licences.txt
InstallPath E:\hmpTest
HKLM/Software/eurovoice/evo50:
evo50SystemVoiceFilesDir C:\TeleSage\sysvox
InstallPath C:\Program Files\evo5.0
evo50LogDir C:\TeleSage\Logs
When my Java application is run with "Run application" from Eclipse it needs to create files that persist across multiple runs of the application. Is it an acceptable practice to place these in the "target" directory? For example, workspace//target/database.db.
Are there events that cause eclipse to delete all files in the target directory?
If the target directory is not a good place to store these files where is a good place? It would be awkward to use System.getProperty("java.io.tmpdir") since the tmpdir is on a different drive and because I would need to mirror the structure of the workspace and project in the tmpdir.
Thank you
The target directory gets deleted when you clean your project (mvn clean). That makes this not the best place to store your data. You should better save it to System.getProperty("user.home"), or pass a directory as a program argument as SpaceTrucker mentioned in the comment, that`s also a good solution.
My recommendation would be the OSGi User Area (-user, intended for user-specific preferences etc.), or the OSGi Instance Area (-data, which is the default home of The Workspace). Take a look at this, and scroll down to "Locations", which explains a bit about these areas.
As for hazardous events, only -clean (the Eclipse arg, not the Maven target) and your deployment process come to mind. -clean should not touch persisted files but works on the internal caches, only, but you might want to try that out to be sure. Your deployment process might consist of "delete contents of installation directory" plus "copy new stuff to installation directory", which would wipe most of the areas which are by default placed inside the installation directory.
I have a Java desktop application that I have written.
During the execution I create folders and files at the default path name defined in the system.
Java.io.files clearly states: By default the classes in the java.io package always resolve relative pathnames against the current user directory. This directory is named by the system property user.dir, and is typically the directory in which the Java virtual machine was invoked.
In addition, I am using IzPack to enable installation and shortcuts creation.
When I'm running my application on my XP computer, after the installation I get a desktop shortcut, and the mentioned files and folders creation are at the location that Izpack installed the Jar. which is the expected behavior.
But when I test this out on a Vista machine, the folders and files are created on the desktop! even though the Jar is at the correct location (c:\program files.. etc).
I want those files to be created at the same folder the Jar is in, and most certainly not at the desktop.
Can anyone give me any insights on what is going on here?
It's because in Vista/Seven, writing to the Program Files folder requires administrative interference, so JVM looks for the next writable location as a fallback: the Desktop (or the User Documents directory). You can easily determine the User home directory in a unified manner on all OSs, though, which is way better than just letting the JVM pick a -- hopefully -- reasonable location.
Since this is a known bug for JVM on Windows, if that doesn't help, the fallback is to check the System Environment variable USERPROFILE which should point at the correct user home folder:
String userHome = System.getenv("USERPROFILE");
I have a NetBeans RCP application that's currently working on Windows and I'm trying to make Linux compatible. The application creates folders and files and modify files as well.
It works fine on Windows without any modification but on Ubuntu it fails creating folders during start up. I know it's a permission issue.
What are my options?
Can the application itself assign the permissions it needs like by running a script using ProcessBuilder?
Thanks in advance!
It all depends on who you are when running the process on Ubuntu, and the path of the folders that you're trying to create. Does this user have permissions to create the folders in that directory? What sort of data are you writing out to disk? Can you use a platform neutral mechanism thats user oriented, like Java Preferences or perhaps:
System.getProperty("user.home")
-or-
System.getProperty("java.io.tmpdir")?
You either need to create required folders as part of a setup process or restrict your IO to folders you have access to (the users home and the temp folder). Notice that on Linux there are standard locations where many folders should be placed and that administrators will frown upon applications that do not follow these standards.
Can you tell what files/folders you need for what purpose?
Looks like the cause of the problem is the difference in path delimiter between Windows and Linux. On linux you should use normal slashes. The error mentions the path:
/home/javier\marauroa.trace.db
As the \ is not a path delimiter but the escape character it is trying to create a file in the folder /home where it does not have permissions.
The path should be:
/home/javier/marauroa.trace.db
You might want to consider putting your apps files in a subfolder called .yourappname so then it would become
/home/javier/.yourappname/marauroa.trace.db
This is what many unix applications do and hide it in normal file listings. To get the path seperator for the system your application is running on you can use the following static field:
java.io.File.seperator