So I'm trying to write my first program that pulls data from the web, and since it's a financial program, I decided to use the (allegedly) easy and simple Yahoo! Finance API. I downloaded the API .jar files, and just to be save, I imported the whole lot of them into Eclipse via the Add External Jars tool.
Problem is, whenever I try to run it, I get a SocketException: Permission Denied runtime error.
The code that I'm running is incredibly basic:
Stock stock = YahooFinance.get("ORCL");
That one line of code should get the value of Oracle (ORCL) stock from Yahoo Finance. Instead it throws the exception.
I have tried everything I can think of:
1) I disabled firewalls 2) I double checked my .jar imports 3) I tested running this line as part of a separate Thread (a desperate, blind move but I was reaching at that point).
I have exhausted every possible angle of research that I can think of, and all I've found so far is this: Sending email using JSP
This looks like a very similar problem, so I attempted the solution suggested: adding the line "-Djava.net.preferIPv4Stack=true" to my eclipse.ini file. It seems to have had no effect.
Just in case, I'm pasting the contents of my eclipse.ini file here too, just in case I put it in the wrong spot or something:
-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_64_1.1.200.v20140603-1326
-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Djava.net.preferIPv4Stack=true
-Dosgi.requiredJavaVersion=1.7
-Xms40m
-Xmx512m
I'm out of ideas right now. I just want to know why that exception is being thrown, and what I can do to prevent it.
Thanks in advance.
Edit: By request, the full stack trace.
Apr 27, 2015 11:54:35 PM yahoofinance.quotes.QuotesRequest getResult
INFO: Sending request: http://finance.yahoo.com/d/quotes.csv?s=ORCL&f=nsc4xab2sa5sbb3sb6sl1sk3sd1t1opghva2kjm3m4sj2sss1sj1sf6sr1qdyee7e9e8rr5p6p5b4s6j4t8&e=.csv
Apr 27, 2015 11:54:35 PM yahoofinance.quotes.QuotesRequest getResult
SEVERE: java.net.SocketException: Permission denied: connect
java.net.SocketException: Permission denied: connect
at java.net.DualStackPlainSocketImpl.connect0(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at sun.net.NetworkClient.doConnect(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.openServer(Unknown Source)
at sun.net.www.http.HttpClient.<init>(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.http.HttpClient.New(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.plainConnect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.connect(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(Unknown Source)
at sun.net.www.protocol.http.HttpURLConnection.getInputStream(Unknown Source)
at yahoofinance.quotes.QuotesRequest.getResult(QuotesRequest.java:83)
at yahoofinance.YahooFinance.getQuotes(YahooFinance.java:332)
at yahoofinance.YahooFinance.get(YahooFinance.java:76)
at yahoofinance.YahooFinance.get(YahooFinance.java:61)
at currency.CurrencyConverter.createWindow(CurrencyConverter.java:35)
at currency.CurrencyConverter.<init>(CurrencyConverter.java:25)
at currency.CurrencyDriver$1.run(CurrencyDriver.java:10)
at java.awt.event.InvocationEvent.dispatch(Unknown Source)
at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
at java.awt.EventQueue.access$500(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.awt.EventQueue$3.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)