Jump to content
Sign in to follow this  
CarlosTheDwarf

Java/JavaScript troubles

Recommended Posts

I wrote a program in java and now need to integrate it in a browser, and not as a Applet.The program uses other files and I need a way to access them. I tried using AJAX but it didnt work out because i needed methods like next() and nextLIne(). Basically i need a replacement for the Scanner class.Ive tried a lot of things and I dont even know what language i will have to use to do what i want so i figured id post it here and hope for some coding master to come save me :) Mucho Grascias,Carlos

Share this post


Link to post
Share on other sites

Is all of the code Javascript? Java and Javascript aren't related, you can't import Java code to run in Javascript. If all of the code is Javascript then there are a couple ways to include it.

Share this post


Link to post
Share on other sites

Well I originally wrote the program in Java because that is the language I am most familiar with. But yes all of the code is now in JavaScript. The conversion went smoothly until i could not find anything to function as the Scanner class does.

Share this post


Link to post
Share on other sites

I'm not familiar with Java, what exactly does the Scanner class do?

Share this post


Link to post
Share on other sites

Well, if all of the code is in Javascript then you can try a couple different methods to attach the external script files. One way, which I've seen Google use, is to just use a document.write statement within the HTML content. If you run the statement after the page finishes loading you'll have problems, but if it is inline in the HTML code then it will work to attach a new script file. In that case you need to close your first script block and then start another one to use the new code.

<script type="text/javascript">document.write("<script src=\"script.js\" type=\"text/javascript\"><" + "/script>");</script><script type="text/javascript">// use the code in script.js here</script>

You can also try creating a new script element and attaching it to the head.

sc = document.createElement("script");sc.src = "script.js";document.getElementsByTagName("head")[0].appendChild(sc);

Share this post


Link to post
Share on other sites
hmmmm thank you very much ill give it a try....the scanner class enables you to work with files on your computer
well or the keyboard for that matter....it reads data into a program i guess is the best way to sum it up

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...