如何部署小程序?
我已经构建了一个小小程序,并且拥有所有 .java 类文件。 我现在如何编译/构建它以便可以在
另外,我在小程序中使用了一些图像。
1) 我需要将这些图像上传到我的网站吗
2) 现在我使用本地路径指向它们,例如 C:\java\project\images
但它全部保存在 1 个类中,以便我可以如果我愿意,可以轻松更改此字符串。 我应该将其更改为什么才能在网络浏览器中运行?
3)我需要上传所有.class文件吗?
I've built a small applet and I have all the .java class files. How can I now compile/build it so I can use it in an <applet>
tag? An eclipse based method would be best.
Also, I'm using some images in the applet.
1) Do I need to upload these images to my website
2) Right now I point to them using my local path e.g C:\java\project\images
but its all kept in 1 class so i can change this string easily if I want. What should I change it to so it'll work in a web browser?
3) Do I need to upload all the .class files?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要上传所有内容,否则没有人能够下载它们! 将所有内容打包到一个 Jar 中,然后让您的小程序从中运行。 有好的文档用于推出小程序遍布整个网络。
对于您的图像,您有两种选择。 将它们包含在 jar 中,或者在运行时通过 HTTP 提供它们。 无论哪种方式,您都必须更改代码,从 C: 驱动器加载它们! 将它们包含在 jar 中可能是最好的 - 无论如何您都会下载它们,并且在一次事务中使用 jar 会更好。
Eclipse 可以使用 Ant 自动为您完成这一切,但我首先会手动完成,以确保您了解发生了什么。 您需要为小程序构建一个 jar 和一个 HTML 页面来启动它,然后将它们上传到您的网络服务器。
You'll need to upload everything, or nobody will be able to download them! Package everything into a Jar, and make your applet run from that. There are good docs for rolling out applets all over the net.
With your images you have two choices. Include them in the jar, or make them available over HTTP at runtime. Either way you'll have to change your code from loading them off the C: drive! Include them in the jar is probably best - you'll be downloading them anyways and it'll be better done with the jar in the one transaction.
Eclipse can be made to do it all automatically for you with Ant, but I'd do it manually at first to be sure you understand what's going on. You'll need to build a jar for your applet and an HTML page to launch it from, and then upload them both to your webserver.
您肯定需要将小程序和图像捆绑在 jar 文件中。
如果图像非常大,并且 Applet 中可能并不总是需要所有图像,那么请将它们作为单个文件部署在您的 Web 服务器上,否则将它们与您的 Applet 一起打包在 jar 中。
如果您将图像与 Applet 一起打包在其 jar 中,那么您应该使用 Class.getResourceAsStream(...) 从类路径加载它们。
如果它们可作为单独的图像文件使用,则从那里的 URL 加载它们。
You definetely need to bundle your applet and images in jar files.
If the images are very large and if all of them may not always be needed in the Applet, then deploy them as single files on your webserver, otherwise package them in the jar with your Applet.
If you package the images with the Applet in it's jar then you should load them from the classpath, using Class.getResourceAsStream(...)
If they are available as individual image files, then load them from there URL.