I have Static Web project in Eclipse and using Http Preview server for development. I want to use root relative path in my resources (e.g. /css/style.css) but I can't figure out how to configure that server to work. There always needs to be context root in path (e.g. http://localhost:8080/myapp). Context root can't be configured as empty. Is there any option I'm missing?
I have found a workaround for this problem if you are working on a Unix variant. It relies on symbolic links, so it probably cannot be made to work on Windows. I claim no points for elegance, but it does seem to work for me on Ubuntu.
First, you create a new static web project in Eclipse that will contain a link to the resource directory. In this case, you can call the project css. Alternatively, give it a descriptive name, and change the context root to css using the project properties dialog.
In a terminal window, change to the project directory for the newly created project. Probably something like ~/workspace/css/. Then replace the WebContent directory with an appropriate symlink:
cd ~/workspace/css
rmdir WebContent
ln -s ../myproject/WebContent/css WebContent
Now return to Eclipse and refresh the css project. You should now see all of your css files in the project explorer.
Run the css project and the original project on the HTTP preview server.
You will have to repeat this process for each of the top-level resource directories.
Related
I have PHPStorm 8.0.1.
PHPUnit is installed via PHAR archive like:
wget https://phar.phpunit.de/phpunit.phar
chmod +x phpunit.phar
sudo mv phpunit.phar /usr/bin/phpunit
PHPUnit works via cli:
user#pc:/usr/bin$ cd ~
user#pc:~$ phpunit --version
PHPUnit 4.3.5 by Sebastian Bergmann.
I followed the instructions from JetBrains website https://www.jetbrains.com/phpstorm/webhelp/enabling-phpunit-support.html#d298258e897
In PHPStorm File->Settings tab PHP/PHPUnit
the radio button Path to phpunit.phar is checked
and value is set to /usr/bin/phpunit
I have a file with a test defined like:
class MyTest extends PHPUnit_Framework_TestCase {
...
At this point PHPStorm marks Undefined class PHPUnit_Framework_TestCase
I've restarted PHPStorm and Computer, but still have the same problem.
I've also tried adding /usr/bin to include path (right click on external libraries in project view, and choose option Configure PHP include paths) without success.
Here's the config for PHPStorm Settings, tab PHP (if it matters):
PHP Language level: 5.5 (finally, generators, etc.)
Interpreter: PHP 5.5 (5.5.9-1ubuntu4.5)
Include path is empty
In order to have a PHAR archive indexed by the IDE it has to have a .phar extension (that's a requirement).
The easiest solution is to place phpunit.phar somewhere in your project (usually it would be PROJECT_ROOT/vendor/ folder).
If having local copy inside the project folder is not desired (for whatever reason; although Composer and other similar kind of tools (bower/npm/etc) are primarily aimed at keeping dependency stuff/packages locally), you may use symbolic links:
either create a symbolic link to that file locally (e.g. PROJECT_ROOT/phpunit.phar --> /usr/bin/phpunit)
or place a full copy (or such symbolic link) in a separate folder outside of the project and then reference it via PhpStorm's Settings | PHP | Include Paths functionality.
The above fix by Calin worked for me too on PhpStorm 2019.1.1, so I'll post it as an answer for easier visibility:
Try right clicking on the .phar and clicking "Exclude phar from project", then clicking "Include phar into project" to refresh it.
In my case, both the .phar file and my .idea folder were pulled from a git commit. I guess PhpStorm didnt realise that the file needed reimporting.
I noticed even though PHP itself can find and run phar that is in its include path, PHPStorm having trouble finding and parsing them.
LazyOne's explanation is correct, however, I didn't need to put it in project folder to be recognized, you can put them in any path as long as its path is introduced to IDE. In my case, I put all phar files in PHP folder, so I just needed to add PHP folder to Include Path list in IDE
Include Path for PHP is under Settings -> Language & Frameworks -> PHP screen (that tiny + at the bottom of screen).
As previous Eclipse user switched to IntelliJ I would like to be able to access folder external to my project from inside the IDE, while developing.
In Eclipse I was using the feature Creating linked resources.
I wonder if there is any feature in IntelliJ that helps me to access external files and folder in a similar way (for instance, if I want to edit the configuration of my application server which is located outside my project).
Yes you can do it by adding an new content root in your module.
You do that from
Project Structure (alt+ctrl+shift+s) - Modules - "My-Module" - + Add Content root
Now you have the contents of the added folder available in your project.
I was searching for a way to get the asset folder link working in IntelliJ as it was working in Eclipse and I found following link in the wikis of libgdx itself.
Linking the asset directories
It describes basically three approaches:
Just copy the asset folder into the desktop folder. (BAD)
Use the asset folder in the android project as working directory for the desktop project through 'Run-Configurations'. (GOOD)
Create a symbolic-link (GOOD)
I tested the 2nd option and it's working fine for me.
I hope it's OK to ask this here. Netbeans forums isn't responding. If not, I'll delete this or ask for it to be deleted. I'm desperate so I'll face the wrath, if any.
I moved my Netbeans projects folder from one directory node to another to make backing up all my stuff easier. BAD MOVE.
Now when I open a project using Files | Open project (ctrl-shift-O) NO source files appear because there is no "+Source Packages" node to expand.
It looks like this for all projects, e.g. one named GBL:
Projects
-GBL
+Libraries
It doesn't look like this anymore:
Projects
-GBL
+Source Packages (How do I get this back?)
+Libraries
The Netbeans Properties for each project shows me the path it's using. Windows 7 Explorer shows me that the src, build, and nbproject folders contain files and ALL the source files are in the src folder for that path.
What have I done and more importantly what should I do to get back to being able to open a project normally?
(I've tried recreating the original Netbeans folder and using Windows Explorer to copy an entire project folder into it but: same result--all I see is the Libraries node under the project's name node.)
I just tried to Clean (and also Build) to see what would happen. Error:
ant -f C:\\Users\\Dov\\Documents\\NetBeansProjects\\BasicShirt -Dnb.internal.action.name=build jar
C:\Users\Dov\Documents\NetBeansProjects\BasicShirt\nbproject\build-impl.xml:[u]231[/u]:
Must set src.dir
I just Set Configuration by right-clicking the project's name and provided a path to the src folder.
NOW I SEE MY SOURCE FILES BUT NOW THIS line in the .xml file is flagged with similar message:
<fail unless="[u][b]test[/b][/u].src.dir">Must set test.src.dir</fail>
NOW what do I do? (Netbeans 7.4.)
If I could get rid of the 7.4 automatic creation of +Test Packages, I might be OK.
If you can help, I'd be very happy.
(I'm considering re-installing 7.3 if available or removing and reinstalling 7.4 and try to avoid the "testing" requirement, but there goes all my many tweaks of 7.4.)
Well, after considerable frustration with the problem, I solved it, essentially.
It's here, in total. My synopsis plus how it helped me follows. In short, I had to set up a new java project based on existing sources using the New Project Wiz and simply direct Netbeans to the sources.
File > New Project
Choose Java Project with Existing Sources.
Type a (new) project name and ...
... make the Project Folder contains the path to where you want the new project to be stored. (For me, this is the folder where Netbeans has been able to find my sources.)
Click Next for the Existing Sources page of the wizard and ...
5a. ... in the Source Packages Folder pane, click Add Folder and ...
5b. ... navigate to your sources and select the source root folder.
Clicking Next goes to the Includes/Excludes pane, which I didn't need to use.
I want to figure out how can I put a file in the root folder of the project and use it in run time, there it will be accessible.
The problem that I have by doing that (placing the file in the root folder)-is that by default it means:
It is not in the classpath of the project.
It is not copied to the bin (output) folder.
I can’t see how my modifications of the file will affect the run process.
As I know there is a similar mechanism in eclipse that does the same:
The Plugin development project has a file-"plugin.xml" in the root folder of the project.
When you make a change in the file without building the project or copying it to the bin folder the changes take place when you run it.
example:
add an extension point in ”plugin.xml” and hit “RUN”, it will take place immediately.
Does anybody have an idea how this mechanism works in eclipse?
Edit - for clarification :
I am interested in how the launcher of eclipse Plugin development project loads\handles the "plugin.xml" file.
I assume when you say you want to put a file in a "root folder of the project" you are refering to a plugin that you are developing and then in runtime you want to get access to that file. Please don't vote me down if I did not understand that question correctly but based on my understanding here are some steps to follow:
Open your MANIFEST.MF file /MANIFEST.MF, this will oepn a multipage editor.
Click on the build tab (third from right).
This is where you specify what resources in your plugin you want the builder to include in the plugin at runtime. You will notice that plugin.xml is already checked which is why extensions get updated each time.
Check the resource on this editor page for the resource you want to be able to load and access at runtime. Behind the scenes this is updating your build.xml which the internal builder uses to figure out what sources to build/add when building/exporting the plugin.
One you have done that this is how you can get access to that file, you get the Bundle for your plugin and call the getEntryMethod with the path to your file and then open in inputstream from there you can load it as a File or whatever you want. Code example below: Hope this helps - Duncan
Bundle myBundle = Platform.getBundle("com.mycompany.myplugin.id")
InputStream in = myBundle.getEntry("/myfile.txt").openStream();
I imported external libraries using absolute path. But I have two work environments, switching between Linux and Windows. Projects are downloaded from SVN. So I was wondering whether I can import these libraries by relative path.
You should declare a variable (Java Build Path -> Add Variable... -> Configure Variable ... -> New) to set the changing path on each system (e.g. FOO_BAR_HOME).
Than you can add the Variable to the Libraries and edit it to point to your library, like
%FOO_BAR_HOME%/lib/foobar.jar
Take a look at the existing variables for usage.
Alternative you can place the library inside the project (e.g. subfolder 'lib'). If you add the library from this location ('Add Jars...' NOT 'Add External Jars...') it will be added by relative path.
Hey I was having this issue as well, but I can offer an alternate solution for those who want to keep the required library locally but outside the directory of the Java Project.
First, add the library you want using the usual "Add External Library/Jar" method.
If you go into the home directory of your Java Project, you should see a .classpath file. Edit this with any text editor you wish, and look for the line that references the library you added. Then, say your library is called lib.jar and you have it one level outside of your project.
Lets say the line says:
<classpathentry kind="lib" path="C:/Users/Public/workspace/lib.jar"/>
Rather than moving lib.jar to your Project's directory, you can just change this line to say:
<classpathentry kind="lib" path="./../lib.jar"/>
and your Java Build path will be updated to look for it in the directory one level above the current project.
Also, to my knowledge if you're running a Mac or any Unix based OS, then the .classpath file will be hidden. In order to access it, you can try opening it from Terminal, by navigating to the directory that your Java Project uses (the actual project folder itself, not the workspace), then either vi or vim ".classpath". Keep in mind that using ls or even ls -a might not work, but trust that it will be there.
Once you've changed it to the specified location, save the file and when you go back into eclipse, the reference should still be working. Keep in mind that the "./" at the beginning is necessary. Just having "../" will not work, or at least it didn't for me.
I did it very simple. I had a lib with an absolute path in my classpath:
/home/glauco/workspace/ltClubs/lib/swingx-core-1.6.2.jar
So i just removed the absolute path from it and it works. Now it's relative xD:
lib/swingx-core-1.6.2.jar
This should be a comment on the previous answer, but the strange reputation system from this site forces me to post a new answer instead... (no comments)
You can use a relative path, but you're missing the './' in it.
Instead of
lib/swingx-core-1.6.2.jar
you should use
./lib/swingx-core-1.6.2.jar
Add the folder containing the dependencies into the JAVA project. Select and right-click the dependencies, "Add to Build Path" pops up as a context menu. This adds the dependencies using relative path instead of the absolute path.