When adding an external JavaScript library to an Eclipse project, should I add a .js file (d3.v2.js) or a tarballed wizard pulled from Github?
Google tells me about it Google. Subsequent Googles remind me of the need for Google.
Directory Tree:
. |-build |---classes |-src |-WebContent |---foo.html |---META-INF |---WEB-INF |-----lib |---d3 |-----d3.v2.js
The relative path from foo.html to d3.v2.js should be: "../d3/d3.v2.js"
- But maybe not. I dont know.
- Whenever I refer to d3.v2.js from foo.html nothing happens. Nothing happens, I do not mean anything is not visually displayed in the browser, which suggests that d3.js even exists.
To add 'd3.v2.js to Eclipse, I took the following steps:
Foo β New β JavaScript source file β Advanced β Link to a file in the file system β /home/tyler/workspace/foo/d3/d3.v2.js
Tried 5 different ways. None of them worked (do you need to use relative, absolute?)
- src = "/ main / Tyler / workspace / Foo / d 3 / d3.v2.js"
- src = "../d3/d3.v2.js"
- src = "/Foo/d3/d3.v2.js"
- src = "d3.v2.js"
So, I deleted the link to d3.v2.js in Eclipse and tried to add it as a library.
Foo β JavaScript resources β Add JavaScript library β User library - Custom library settings β Create β βD3β β Add .js file β d3.v2.js (location: / home / Tyler / workspace / Snotra / d3
I tried a bunch of ways.
- src = "d3.v2.js"
- src = "../d3/d3.v2.js"
src = "/Foo/d3/d3.v2.js"
Any ideas? I know this is very simple, but I just donβt understand the basics of adding JavaScript libraries to Eclipse.
foo.html
<!DOCTYPE HTML> <html lang="en"> <head> <meta http-equiv="content-type" content="text/html" charset="utf-8" /> <title>Tyler J. Fisher</title> <link rel="stylesheet" href="master.css" /> <script type="text/javascript" src="../d3/d3.v2.js"></script> </head> <body> <section id="foo_view"> <script type="text/javascript"> document.write("test"); var dataset[1,2,3,4,5]; d3.select("body").selectAll("p") .data(dataset) .enter() .append("p") .text("RABBLE"); </script> </section> </body> </html>
document.write ("test"); works.
The d3.js code does not work.
So (maybe):
- The relative path should be turned off (or maybe I should use absolute paths)
- Tomcat6 does not serve JavaScript properly (due to human error)
- Eclipse does not serve JavaScript properly (due to human error)
user1260503
source share