|
|
A simple Google search found this[^] document containing all the detail you need?
It's time for a new signature.
|
|
|
|
|
Hello Friends
I want to install java on client machine if it is not installed through applet tag.I did through object tag but same I want to do through Applet tag.
Here is Object Tag:
<object id="viewer" classid="clsid:CAFEEFAC-0016-0000-0000-ABCDEFFEDCBA"
codebase="http://java.sun.com/update/1.6.0/jinstall-6-fcs-windows-i586.cab"
width=360
height=557 >
<param name="code" value="org.jdesktop.applet.util.JNLPAppletLauncher" >
<param name="archive" value="http://download.java.net/media/applet-launcher/applet-launcher.jar,
This code automatically installs java but I want to do same through applet tag.I made some changes but it is not asking user to install.here is applet tag and please let me know wat do i need to change to install java?
Applet tag:
<applet
code="print_canvas3d.PrintCanvas3D "
codebase="http://java.sun.com/products/plugin/autodl/jinstall-1_4_2-win.cab"
width=360
height=557
archive="http://www.styku.com/wer.jar,
http://download.java.net/media/applet-launcher/applet-launcher.jar,
And one more prob is If I provide class name directly in code=pkg.classname then it is giving me right Id but If i use JNLPAppletLauncher at the same place then I am getting the Id of jnlpLaunched that I dont want ,I want the id of mine main class.How can i get?
Thanks & Regards
Yogesh
|
|
|
|
|
Hi Guys
I found Something and now I need ur help.Here is the code below,After using this code,It asks If java is uninstall but after that it is not loading my jar file,is it some path issue. Or if java is already installed on sytem then it loadds my jar file.
<applet
code="org.jdesktop.applet.util.JNLPAppletLauncher "
codebase="http://java.sun.com/products/plugin/1.3/jinstall-13-win32.cab#Version=1,3,0,0"
width=360
height=557
archive="http://www.sample.com/view/view.jar,
http://download.java.net/media/applet-launcher/applet-launcher.jar,
http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dcore.jar,
http://download.java.net/media/java3d/webstart/release/j3d/latest/j3dutils.jar,
http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar,
http://download.java.net/media/gluegen/webstart/gluegen-rt.jar,
http://download.java.net/media/java3d/webstart/release/vecmath/latest/vecmath.jar"
id="viewer">
<param name="codebase_lookup" value="false">
<param name="subapplet.classname" value="canvas3d.Canvas3D">
<param name="subapplet.displayname" value="My Java 3D Applet">
<param name="jnlpNumExtensions" value="1">
<param name="jnlpExtension1" value="http://download.java.net/media/java3d/webstart/release/java3d-latest.jnlp">
<param name="progressbar" value="true">
<param name="noddraw.check" value="true">
</applet>
Any Ideas Guys Now.
Regards
Yogesh
|
|
|
|
|
Good, you found solution
♫ 99 little bugs in the code,
99 bugs in the code
We fix a bug, compile it again
101 little bugs in the code ♫
|
|
|
|
|
Hello Guys
i am trying to write a file to server with URLConnection.And here is the code below.I created one file at that location and with my code trying to write some thing but nothing is happening.I need some ideas.Or is it some issue with access to server on that file?
Code:
try {
URL url;
URLConnection urlConn;
DataOutputStream dos;
DataInputStream dis;
url = new URL("http://sample.com/test/file.txt");
urlConn = url.openConnection();
urlConn.setDoInput(true);
urlConn.setDoOutput(true);
urlConn.setUseCaches(false);
dos = new DataOutputStream (urlConn.getOutputStream());
String message = "Yahoooooooo";
dos.writeBytes(message);
dos.flush();
dos.close();
dis = new DataInputStream(urlConn.getInputStream());
String s = dis.readLine();
dis.close();
}
catch (MalformedURLException mue) {
addTextField.setText("mue error");
}
catch (IOException ioe) {
addTextField.setText("IO Exception");
}
Any Ideas guys.
Thanks & Regards
Yogesh
|
|
|
|
|
For as far as I know webservers will not allow you to do this, at least not the way you want by opening or creating a file remotely and writing to it.
What you could do is write some servlet or JSP code on the remote server that accepts POST data and writes that to a file. You can then POST any content to that JSP / Servlet and store data that way.
EG:
server A has a servlet called /StoreFile
server B calls http://serverA/StoreFile
with POST data
fileName=file1.txt&data=<yourencodeddata>
|
|
|
|
|
Hello Gerban
THanks for ur reply but I am reading the file from server in same way.Thats why I thought that writing is also possible in the same way.
And i got this solution from net.
Anyway,I will try ur way also but still If u know any other way then please let me know.
Thanks Again for ur replay.
Regards
Yogesh
|
|
|
|
|
Reading should never cause you any issues, as this is the primary reason to have a webserver (get access to remote files).
The real question is why would you want to have unprotected writing to a webserver at all (which you are doing if you open a file on a remote server and just start writing in it). You would create a serious security risk.
If it is at all possible to write directly to a webserver from a remote connection then that will be a security setting on the webserver, and not on the Java side of things. So maybe you should also ask this question on some forums relating to Tomcat / Apache or whatever webserver you are running.
|
|
|
|
|
Thanks For ur Reply.
Yeah,I understand this would be a security risk.So I have to drop this way.
Thanks
Regards
Yogesh
|
|
|
|
|
Hello Friends
I want to add progress bar moving while I am reading a file.
Any Ides Guys?
Thanks & Regards
Yogesh
|
|
|
|
|
The simplest option is simply to start a progress bar running in indeterminate mode (i.e. the bar just bounces back and forwards to show you that something is happening), then load the file, then stop the progress bar when you are finished loading. That way you never need to worry about how big the file is.
The alternative is to get the length of the file before you start (create a File object, and call length()) then track the number of bytes you have read in as a percentage of the total and update the progress bar periodically. Don't update the progress bar too often (e.g. if you have a 2Mb file and you update the progress bar after reading every individual byte, you will be updating the progress bar over 2 million times, which is obviously not a good idea). Make sure you don't load the file on the Swing event handling thread, but make sure that you do update the progress bar on the EDT.
Or, you could use a ProgressMonitor, which is an inbuilt progress dialog that is sometimes useful.
Progress bar tutorial here:
http://download.oracle.com/docs/cd/E17409_01/javase/tutorial/uiswing/components/progress.html[^]
|
|
|
|
|
Thanks A Lot.Mr David
Regards
Yogesh
|
|
|
|
|
Hello Friends
I am using file object to with URL path as parameter to pass filename to some function.But it is not creating File Object.I tried like this:
String filePath="http://test.com/folder/file.txt
File f = new File(new URL(filePath).toURI());
And like this too
File f = new File(new URL(filePath).getPath());
but it is crashing at this point.
Any Ideas Guys.
Thanks In Advance.
Regards
Yogesh
|
|
|
|
|
yogeshs wrote: but it is crashing at this point.
Any Ideas Guys.
Well perhaps if you showed the error that you received we may be able to help work out what is going wrong. However, I am not sure that you are allowed to create files on a client machine in this way.
It's time for a new signature.
|
|
|
|
|
Hello Sir
Actually I am facing some exception when I run and its java.lang.reflect.InvocationTargetException.
May be this one useful for you.I searched for this but didnt found anything.
Thanks & Regards
Yogesh
|
|
|
|
|
The explanation is here[^], also some discussion about what information it holds. You should catch this and then display its cause details to help identify what is going wrong.
It's time for a new signature.
|
|
|
|
|
Guys
I'm trying to applying singleton pattern to TCP server client application
But I get some run time exceptions.I tryed out diffrent ways.
Please give me your suggetions to correct this
here TCPServer is the Singleton
in my client(TCPClient) I want to access TCPServer but I can not do it.
TCPServer Class
import java.io.*;
import java.net.*;
class TCPServer {
private String capitalizedSentence;
private ServerSocket welcomeSocket;
private String clientSentence = new String(" d");
private BufferedReader inFromClient;
private DataOutputStream outToClient;
private Socket connectionSocket;
private static TCPServer instance = null;
private TCPServer() throws Exception {
}
private TCPServer(int socketID) throws Exception {
if( welcomeSocket==null){
}
}
public static TCPServer getInstance() throws Exception {
if(instance == null) {
instance = new TCPServer();
System.out.println("This is new server instance created");
}
else if(instance !=null){
System.out.println("This is old instance");
}
return instance;
}
public void method()
{
System.out.println("This is server");
}
public void run() throws Exception{
welcomeSocket = new ServerSocket(6789);
while(clientSentence.equals("exit")!=true) {
connectionSocket = welcomeSocket.accept();
inFromClient = new BufferedReader(new InputStreamReader(connectionSocket.getInputStream()));
outToClient = new DataOutputStream(connectionSocket.getOutputStream());
clientSentence = inFromClient.readLine();
System.out.println("Recived from client : " + clientSentence);
capitalizedSentence = clientSentence.toUpperCase() + '\n';
outToClient.writeBytes(capitalizedSentence);
}
}
}
TCP Client Class
import java.io.*;
import java.net.*;
class TCPClient {
private String sentence,modifiedSentence;
private DataOutputStream outToServer;
private BufferedReader inFromServer;
private Socket clientSocket;
private BufferedReader inFromUser;
public TCPClient() throws Exception{
inFromUser = new BufferedReader(new InputStreamReader(System.in));
clientSocket = new Socket("192.168.1.2", 6789);
outToServer = new DataOutputStream(clientSocket.getOutputStream());
inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
}
public String getSentence()
{
return sentence;
}
public void setSentence(String str)
{
this.sentence=str;
}
public String getModifiedSentence()
{
return modifiedSentence;
}
public void setModifiedSentence(String str )
{
this.modifiedSentence=str;
}
public void run() throws Exception{
System.out.println("Enter a String");
sentence = inFromUser.readLine();
outToServer.writeBytes(sentence + '\n');
modifiedSentence = inFromServer.readLine();
System.out.println("FROM SERVER: " + modifiedSentence);
TCPServer mySever = TCPServer.getInstance();
clientSocket.close();
}
}
Calling class
To Server
public class Server{
public static void main(String[] args) throws Exception{
TCPServer x = TCPServer.getInstance();
x.run();
}
}
To client
public class Client{
public static void main(String[] args) throws Exception{
TCPClient client = new TCPClient();
client.run();
}
}
|
|
|
|
|
Nadunwow wrote: But I get some run time exceptions.
Well it's not easy for us to guess what those may be. Please explain exactly what exceptions you get, and where in the program (i.e. line of code) that they occur.
It's time for a new signature.
|
|
|
|
|
I fixed them
and Not code is updated.
Then I get another problem
I need only one instance of siglton(TCPServer).
But My client connect to one instance but How can I access that instance in TCP client ?
if I can not is it possible to pass the TCPClient as a object to TCPServer ?
What is the procedure I should follow ? Any idea ?
|
|
|
|
|
Sorry, but I'm not sure what you are asking.
It's time for a new signature.
|
|
|
|
|
I'm not sure he is either.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
There could be several answers depending on the /real/ question. Are you looking for:
A single server that many clients connect to?
A server that accepts one and only one connection?
A client that can only connect to the server once?
Just because you've read about the singleton, does not mean it is the right pattern here.
Panic, Chaos, Destruction.
My work here is done.
or "Drink. Get drunk. Fall over." - P O'H
|
|
|
|
|
I am just started playing with java an I am having this issue. I did the simple hello world app like this:
class HelloWorldApp {
public static void main(String[] args) {
System.out.println("Hello World!");
}
}
And when I run it in eclipse the console shows Hello World!, But if I run it in the terminal as "java Hello?WorldApp.class"
It will not run it just gives me the error "Class not found". Why is this? Thanks. Running Ubuntu 10.04.
Exception in thread "main" java.lang.NoClassDefFoundError: HelloWorldApp/class
Caused by: java.lang.ClassNotFoundException: HelloWorldApp.class
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at java.lang.ClassLoader.loadClass(ClassLoader.java:321)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
at java.lang.ClassLoader.loadClass(ClassLoader.java:266)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:334)
Could not find the main class: HelloWorldApp.class. Program will exit."
Y*Live Long And Prosper*Y
|
|
|
|
|
Why did you add ".class" after the class name ? You should execute it like this: java HelloWorldApp
|
|
|
|