/    Sign up×
Community /Pin to ProfileBookmark

JxBrowser Safari Browser not working

Hi, I am writing a java application that loads my website in a Safari JxBrowser component, unforunatly it wont work, this is the error I get

[CODE]
Exception in thread “main” com.teamdev.jxbrowser.UnsupportedBrowserTypeException: Safari engine doesn’t support current environment: Windows 7, 6.1, Service Pack 1, CPU arch: x86, Java Oracle Corporation 1.7.0_03, 32-bit
at com.teamdev.jxbrowser.BrowserFactory.createBrowser(Unknown Source)
at Main.main(Main.java:53)
[/CODE]

(I have aso tried this with the x64 JDK, and still get the error)

This is the code I am using

[CODE]
import com.eaio.uuid.UUID;
import com.teamdev.jxbrowser.Browser;
import com.teamdev.jxbrowser.BrowserFactory;
import com.teamdev.jxbrowser.BrowserType;
import java.awt.BorderLayout;
import java.io.*;
import javax.swing.JFrame;

public class Main {

static public String getContents(File aFile) {
StringBuilder contents = new StringBuilder();
try {
BufferedReader input = new BufferedReader(new FileReader(aFile));
try {
String line;
while (( line = input.readLine()) != null){
contents.append(line);
}
}
finally {
input.close();
}
} catch (IOException ex){
}
return contents.toString();
}

static public void setContents(File aFile, String aContents) throws FileNotFoundException, IOException {
if (aFile == null) {
throw new IllegalArgumentException(“File should not be null.”);
}
if (!aFile.exists()) {
throw new FileNotFoundException (“File does not exist: ” + aFile);
}
if (!aFile.isFile()) {
throw new IllegalArgumentException(“Should not be a directory: ” + aFile);
}
if (!aFile.canWrite()) {
throw new IllegalArgumentException(“File cannot be written: ” + aFile);
}
Writer output = new BufferedWriter(new FileWriter(aFile));
try {
output.write( aContents );
}
finally {
output.close();
}
}

public static void main(String[] args) throws IOException {

Browser browser = BrowserFactory.createBrowser(BrowserType.Mozilla);

JFrame frame = new JFrame();
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(browser.getComponent(), BorderLayout.CENTER);
// frame.setUndecorated(true);
frame.setSize(800, 600);
frame.setLocationRelativeTo(null);
frame.setVisible(true);

String uuid = “”;
UUID id = new UUID();

java.net.InetAddress localMachine = java.net.InetAddress.getLocalHost();

boolean mkdir = (new File(System.getenv(“APPDATA”) + “\.mysitedata”).mkdir());

if( mkdir ) {
String fileName = System.getenv(“APPDATA”) + “\.mysitedata\system.txt”;

File f = new File(fileName);
if(!f.exists()){
f.createNewFile();
setContents(f, “UUID: ” + id.toString() + “, PC_NAME: ” + localMachine.getHostName() + “, LOGGED_IN_USER: ” + System.getProperty(“user.name”) + “”);
uuid = id.toString();
}else{
String contents = getContents(f);
String[] parts = contents.split(“, “);
String[] UID = parts[0].split(“: “);
uuid = UID[1];
}
}

browser.navigate(“http://mysite.co.uk?access=app&uuid=” + uuid);

}
}
[/CODE]

Also I can create the system.txt file in the correct location, but cannot seam to read it, any Ideas

Thank-you

Vinny

to post a comment
Java

0Be the first to comment 😎

×

Success!

Help @vinny619 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...