System.setProperty and java.lang.noSuchMethodError (!)

M

Marco

The method System.setProperty("name", "value"), if user haven't SUN
java, give at runtime the error "java.lang.noSuchMethodError:
java/util/Properties: Method
setProperty(Ljava/lang/String;Ljava/lang/String)Ljava/lang/Object; not
found".

There is an alternative of System.setProperty compatible with Microsoft
java?
 
A

Andrew Thompson

Marco wrote:
....
There is an alternative of System.setProperty compatible with Microsoft
java?

You are doing end users a disservice by supporting this
obsolete and insecure JVM. Encouraging the ever shrinking
pool of IE/MSVM users to upgrade to the Sun Java plug-in
(or Mozilla/Opera..) would be a better course of action.
 
C

Chris Smith

Marco said:
The method System.setProperty("name", "value"), if user haven't SUN
java, give at runtime the error "java.lang.noSuchMethodError:
java/util/Properties: Method
setProperty(Ljava/lang/String;Ljava/lang/String)Ljava/lang/Object; not
found".

Look up setProperty in the API docs. See the little bit where it says
"Since:" and "1.2". That's your cue that the method is not available in
Java 1.1 and earlier, which include Microsoft's JVM.
There is an alternative of System.setProperty compatible with Microsoft
java?

Yes, there is. It's System.getProperties, followed by setProperty on
the resulting Properties object. However, you can't do it in an
unsigned applet or without asking for appropriate permissions.

Incidentally, it's irresponsible to ask people to install the Microsoft
JVM. Microsoft is no longer distributing security updates to that
product, and it constitutes a potential risk of virii and other
nastiness. I'd strongly encourage you to abandon that nonsense, and
either implement what you're working on in a more modern version of
Java, or if you can't do that then go for Flash or JavaScript instead.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
 
M

Marco

There is an alternative of System.setProperty compatible with Microsoft
Yes, there is. It's System.getProperties, followed by setProperty on
the resulting Properties object.



How can I set Properties object, if I can't use
java.util.Properties.setProperty(String,String)?


However, you can't do it in an
unsigned applet or without asking for appropriate permissions.

No problem, I need to do a signed applet.
Incidentally, it's irresponsible to ask people to install the Microsoft
JVM.

No, no, I don't need Microsoft JVM, my hope is that user have SUN JVM, but I
write a web applet, and I know many people that have only Microsoft JVM
installed, and I want compatibly with ALL JVM. I think that not all user of
my applet can be able (or they not want) install SUN JVM.
 
A

Andrew Thompson

Marco wrote:
....
No, no, I don't need Microsoft JVM, my hope is that user have SUN JVM, but I
write a web applet, and I know many people that have only Microsoft JVM
installed, and I want compatibly with ALL JVM.

How do you account for 'no java'?
Forget IE for the moment - some browsers will have NO VM at all
(including some release of IE, but I thought I should stress
that it might hit almost any browser - most browser makers
offer 'Java/No Java' versions).
 
M

Marco

No, no, I don't need Microsoft JVM, my hope is that user have SUN JVM,
How do you account for 'no java'?
Forget IE for the moment - some browsers will have NO VM at all
(including some release of IE, but I thought I should stress
that it might hit almost any browser - most browser makers
offer 'Java/No Java' versions).

I want studying java web start... but if applet too work, it is better. But
I need an equivalent of System.setProperty that work with Java Sun and with
Java Microsoft too...

There isn't a solution?
 
A

Andrew Thompson

Marco said:
...
I want studying java web start...

It is a good option generally, though slighlty less so for applets.
Compare these two examples ..
<http://www.physci.org/pc/jtest.jnlp>
<http://www.physci.org/pc/jtest-applet.jnlp>

Note that the Java Plug-In (Java 1.3+, AFAIR) supports
Java Web Start. An IE with the MSVM or a browser with
no VM might need to determines the correct application
by 'using the web service'.
..but if applet too work, it is better. But
I need an equivalent of System.setProperty that work with Java Sun and with
Java Microsoft too...

There isn't a solution?

What system property/s do you need to change, and why?
 
M

Marco

It is a good option generally, though slighlty less so for applets.
My jar work well as application, but as applet I have some problem to set
the equivalent of
"-Djavax.net.ssl.trustStore=pwd -Djavax.net.ssl.trustStorePassword=123456".
An application (non applet) is good for me, only I need automatic
installation of java plugin, if the user need it.
What system property/s do you need to change, and why?

As I said, some as the following:

System.setProperty("javax.net.ssl.trustStore", "C:\\prcorso\\pwd.jks");
//not very good for compatibility, but now this isn't the question. This
must work in all JVM of browsers (IE, above all).
System.setProperty("javax.net.ssl.trustStorePassword", "123456");

The applet must send username, password and some elements that the user
inserted with an encripted (SSL) connection with the website of the applet,
and receive an eleboration with SSL.

If I compile my applet with 1.2 or 1.3, I use the library
jsse-1_0_3_03-gl.zip. If I compile with 1.4 or 1.5, the library for SSL is
not necessary.

Client and server are build as in the page
http://tvilda.stilius.net/java/java_ssl.php
 
M

Marco

It is possible to find source code of SUN Property class, and insert it as a
library for jar file?
 
R

Roedy Green

You are doing end users a disservice by supporting this
obsolete and insecure JVM. Encouraging the ever shrinking
pool of IE/MSVM users to upgrade to the Sun Java plug-in
(or Mozilla/Opera..) would be a better course of action.

It is over 10 years old. Could you imagine using a Netscape from that
same vintage?
 
M

Marco

There is an alternative of System.setProperty compatible with Microsoft
It is possible to find source code of SUN Property class, and insert it as
a library for jar file?

I rewrite the following class:

// source of msft/Proprieta.java
//**********************

package msft;

import java.util.Hashtable;
import java.util.Properties;

public class Proprieta extends Properties
{
public synchronized Object setProperty(String s, String s1)
{return put(s, s1);}

//constructors
public Proprieta()
{super(null);}
public Proprieta(Properties properties)
{super(properties);}
}

//**********************

This work, if I use, in the init of main class:

//**********************
try
{
msft.Proprieta p=new msft.Proprieta(System.getProperties());
p.setProperty("javax.net.ssl.trustStore",
"D:\\Siti\\equazioni\\java\\jar\\pwd.jks");
p.setProperty("javax.net.ssl.keyStore",
"D:\\Siti\\equazioni\\java\\jar\\pwd.jks");
p.setProperty("javax.net.ssl.keyStorePassword", "123456");
p.setProperty("javax.net.ssl.trustStorePassword", "123456");
System.setProperties((java.util.Properties)p);
}
catch (Exception e)
{System.out.println("errore: "+e);}
//**********************

N.B. I haven't tested it with signed applet, because I still need understand
Microsoft procedure, but if i use "msft.Proprieta p=new msft.Proprieta();"
for avoid com.ms.security.SecurityExceptionEx in System.getProprieties(),
p.setProperty work as espected.
 
R

Roedy Green

N.B. I haven't tested it with signed applet, because I still need understand
Microsoft procedure, but if i use "msft.Proprieta p=new msft.Proprieta();"
for avoid com.ms.security.SecurityExceptionEx in System.getProprieties(),
p.setProperty work as espected.

That's your problem. See http://mindprod.com/jgloss/properties.html
there are safe and restricted proprieties. You can't get hold of the
entire set of properties is an unsigned applet. You are not going to
sign it for MS. You can't even buy the old certs anymore.

see also http://mindprod.com/applets/wassup.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top