So I have a problem with loading the exact json_GetTownInfo.php file on Web Host where applet located. On my computer where I code the project i wrote URL myhost.com/jquery/json_GetTownInfo.php and it successfully loads it testing. When I change the URL to ../jquery/json_GetTownInfo.php and put my compiled dara.jar to Web Host it won't load at all nor myhost.com/jquery/json_GetTownInfo.php as a string in URL object...
So please help me to determine how to properly use URL's in java to load it on Web Host...?
where myhost.com - should be with http, because forums denies post...
My located JAVA files are here: myhost.com/java , java.html(Where to show applet) and main dara.jar(Applet file). JSON(PHP) is located here: myhost.com/jquery , json_GetTownInfo.php.
java.html :<applet code="ArcanumUniverse.class" archive="dara.jar" width="800" height="600"/>
json_GetTownInfo.php :<?php include "../style.class.php"; $style = new style; $get_places = $style->get_town_info("place_ID,place_Name,place_MapX,place_MapY,place_ImageMap", 1); echo json_encode($get_places); ?>
ArcanumUniverse.java(compiled in dara.jar) :URL url; JsonReader reader = null; try { url = new URL("../jquery/json_GetTownInfo.php"); try { reader = new JsonReader(new InputStreamReader(url.openStream())); Type listType = new TypeToken<List<TownData>>() {}.getType(); List<TownData> data = new Gson().fromJson(reader, listType); System.out.println(data.get(0).place_ID); System.out.println(getCodeBase()); placee = data.get(0).place_ID; //System.out.println(data.getTownIndex()); /*for (int i = 0; i < data.size(); i++) { data2.add(new TownData(data.get(i).place_ID)); }*/ } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); }